To focus on the question here, we can say that I have one database layer and one application layer. So for the application to get access to the database I have to go through the database layer (of course).
Now the thing is that I want to write my queries using LINQ. And I could go two different paths here. One way [A] would be to create about 300 individual functions in the DBLayer, and call them from the Application (eg. GetAllUsers()
).
OR [B] the DBLayer could more or less just offer a DBContext and then I can run the LINQ queries from the Application Layer (DBContext.GetAll<Users>().Where(x => x...
).
I think that the [B] path would be more appealing, or at least less annoying since it wouldn't be so filled up with small functions. But what would you say?
However the problem with the [B] path is that, if I can avoid it I don't want to have a reference to NHibernate in the Application, but I don't seem to get access to the LINQ for NHibernate functions without referencing it. Is there a good solution to this?