Sharing LINQ-to-SQL classes / models between multiple projects in a solution

I have several C # projects in Visual Studio solution right now, and all of them will use the same SQL Server database.

What is the appropriate way to share LINQ-to-SQL classes between projects?

I am considering copying files dmblinto each project, but I think this may be too redundant. Is there a better way to approach this?

+3
source share
5 answers

Suppose you need to split the database access code between projects, not linq-2-sql classes.

(DAL), , linq-2-sql, .

DAL .

+4

: . , .

+2

, Linq- , Linq. ? , "" , Linq, "" Linq-.

, Andrew Florko , .

+2

, , DBML. . , , , , .

, . , DAO.

0

Model, (DAL) , .

DAL will encapsulate the details of how it interacts with the database (in this case, LINQ to SQL is used) and hide them behind a well-defined interface that makes sense for the application.

In addition, since classes created from a DBML LINQ to SQL file are just ordinary CLR (POCO) objects, I see no problem with directly representing them as part of your DAL interface.

0
source

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


All Articles