I am using DataClassesDataContext to map all the tables from the db into my asp.net application.
For doing CRUD operations i have made static classes with methods, and inside every method a instantiate DataClassesDataContext.
For instance:
public static class UserQ { public static User getUserById(int userId) { DataClassesDataContext db = new DataClassesDataContext(); var requestedUser = (from u in db.Users where u.User_id == userId select u).First(); if (requestedUser != null) return (User)requestedUser; else return null; } } I aam not sure if this way of doing database operations in a web application is safe? If not, can you suggest please a better pattern?