John dean
John dean

Reputation:

DataContext in CodeBehind?

Im working on an ASP.NET app and using LINQ to SQL for the first time and something seems off. Usually on a web project, there is a data access layer, a biz layer and the preso layer....does linq to sql not work this way? I see where other developers have put the DataContext directly into the Preso layer and are calling the DB via linq from there. Is that the correct way to do it? no biz layer? Thanks John

Upvotes: 0

Views: 221

Answers (3)

Christian C. Salvadó
Christian C. Salvadó

Reputation: 828012

An usual practice is also to implement the Repository pattern:

Upvotes: 0

Andrew Hare
Andrew Hare

Reputation: 351728

If you are looking for more layers of abstraction between you and the database, perhaps LinqToSql is no the right choice for you. Perhaps the ADO.NET Entity Framework is a better choice.

Upvotes: 1

Mehrdad Afshari
Mehrdad Afshari

Reputation: 422270

You can encapsulate LINQ in a data access layer. But for most small to mid size projects, it's good enough.

You should always have the high level goals in mind. You use object orientation and design patterns to lower the cost of implementation and maintainability. There is no need to overengineer when the simplest and fastest design satisfies most of the needs and is maintainable enough.

Upvotes: 0

Related Questions