Using LINQ generated classes directly?

LINQ will generate a set of classes from SQL files. Should they be used directly or should they be wrapped in another class so that the model is not implementation dependent?

+3
source share
3 answers

You can do it anyway. As a rule, I transfer Linq classes in SQL to the repository, but if the application is small, you can directly use the repository methods.

If the application is larger, you can add a business layer.

+2
source

sql, Linq-To-Sql, , . , ( , ).

, "ORACENT" ORM, Entity Framework. , , ,

, , Ling Sql. , .

+1

, - , (GetOne(), Save(), Search(), Delete() ..).

, "" , , , LINQ . , ToList() IQueryable<T> , LINQ to Objects.

, , , LINQ to SQL , , LINQ to SQL Entity Framework (), .

The only exception that I would make is when LINQ to SQL objects must cross the service boundary, i.e. Dispatched as data transfer objects to or from the WCF service. In this case, I consider it a good idea to have a separate, lightweight object model that supports serialization - do not send your LINQ to SQL objects directly through the wiring.

+1
source

Source: https://habr.com/ru/post/1724359/


All Articles