开发者

Solution structure using LINQ

开发者 https://www.devze.com 2023-03-24 07:16 出处:网络
My basic ASP.NET structure is always 3 projects DAL = Data accesses layer - dealing with the db Bussiness logic layer - dealing with all action and functions

My basic ASP.NET structure is always 3 projects

  • DAL = Data accesses layer - dealing with the db
  • Bussiness logic layer - dealing with all action and functions
  • Presentation layer - Present data to website

Do i need to change my basic structure because i want to develop with LINQ to sql?

What is the best structure开发者_Python百科 to develop with LINQ to sql?


No. The structure, can remain the same. But I would use Entity Framework instead, that's what Microsoft is pushing in the near future.


LINQ to SQL is a very simple ORM, a thin layer on top of your database.
So if you decided to use it in your project, treat it as the DAL.


There is no need to change the structure of you projects. Your DAL basically becomes a place for your LinqToSql models, classes etc.
Like other suggested, you should consider Entity Framework (LinqToEntities) instead of the no-longer-in-development LinqToSql.
You can read on Entity Framework here.


For new projects, I'd start with this structure and adapt to requirements as necessary:

  • C# POCO Domain Objects (a.k.a. "business" objects)
  • Entity Framework 4.1 Code First
  • WCF Web Services
  • ASP .NET MVC 3 using Razor, or WebForms if you have some very compelling reason to do so

Your web applications should connect to the WCF services for data access.


Use POCOs.

If you're really set on using LINQ to Sql, use it to populate POCOs. Heck, use whatever you want, but send them back to your Business Logic and UI as a POCO. As mentioned before, L2S is not 'blessed' by microsoft anymore, which is the beauty of using POCOs. Let's face it, it's only a matter of time before EF isn't 'blessed' and the next big thing comes along.

If you use POCOs, the only thing you need to change is your DAL and how you get data to create your POCOs. Everything else will remain unchanged.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号