LINQ and 3-Tier

We have established coding standards using strongly-typed datasets in our 3-tier model--very close to the model presented athttp://msdn2.microsoft.com/en-us/library/aa581771.aspx.We are trying to figure out how we should introduce LINQ into this model.We currently have all data access code in the .xsd and business logic at seperate BLL level.With LINQ, it seems that our .dbml replaces the strongly-typed dataset, and that LINQ code should be used at the next level up in our BLL.Is this proper or should we use partial classes utilizing LINQ at the .dbml level to extend its functionality and leave pure business logic in the BLL?

[868 byte] By [NatePrince] at [2008-1-5]
# 1

The .dbml file is like your typed dataset, the designer creates an entity class that maps your database table and contains relation between tables as well. The code that uses the entity class, the one with LINQ query can be written in the business logic layer. Just if you don't know, Linq can query typed dataset as well, so you can avoid to create the data access layer back.

Best,

Fabio

Bltfast at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,LINQ Project General...
# 2

Thanks for your help Fabio!

Nate

NatePrince at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,LINQ Project General...
# 3

Hello,

I have also a question about this.

We have our logic layer. We use the data layer like List<Customer> GetCustomers(); (Customer class is in BLL)

Can we use LINQ without putting linq code into this classes?

We currently use no datasets but building the objects by the results of the sql queries.

hope you understand.

Dirk

DirkR. at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,LINQ Project General...
# 4

If you have a method : List<Customer> DataLayer.GetCustomers() which builds the objects by the results of sql queries... it can instead build the objects by the results of linq queries.

The Customer type is clearly known to the DataLayer, so internally it can

var query =

from c in DB.Customers

select new Customer(c.Name, c.Address, c.Hobby, c.CustomerID);

List<Customer> ResultList = query.ToList();

return ResultList;

DavidBuchanan at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,LINQ Project General...
# 5

Yes...

but to do that, I have to put linq attributes to the customer class....but this lies in the bll

DirkR. at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,LINQ Project General...
# 6
To use the example that David gives, there is no need for LINQ attributes on the Customer class. It can be a standard class with nothing related to LINQ.
Only DB.Customers is based on LINQ to SQL.
FabriceMARGUERIE at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,LINQ Project General...
# 7

But then I loose the object tracking capabilities, don't I?

Because I create a Logic.Customer object from each DB.Customer, and then work with the Logic.Customer in my app.

DirkR. at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,LINQ Project General...
# 8
You do, unless your Logic.Customer is a wrapper around DB.Customer. But that would create a strong dependency between your layers. Something you want to avoid it seems.
FabriceMARGUERIE at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,LINQ Project General...
# 9

Fabrice MARGUERIE wrote:
But that would create a strong dependency between your layers. Something you want to avoid it seems.

yes!

Thanks! that's all Smile

DirkR. at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,LINQ Project General...

Visual Studio Orcas

Site Classified