views:

62

answers:

1

I'm busy on making a Business Logic Layer. Now I had a problem since i want to program using c# and the whole project i have to make a module for is vb.net based. I have solved this using a new project in the solution. This project will maintain the dataclasses and Business Logic. Now i've run to an issue, atleast i don't know what to do here. This is what i've done so far:

  • I've build a new project in a solution in which i can't use C#, since it's all vb.net
  • I've made dbml's for each type of entity i want to use in my future application.

Now i'm working on the Business Logic Layer. I have dbml's for each type i have to use in my app. For example I have a dbml called "Relations". Now i want to set up BLL functionality to return me a list of Relations based on a searchstring input. Now should i implement a class called Relations.cs and add constructor logic etc. and make a list of this type and return this list, or should i just use my Datacontext from the relations dbml and use linq to return a list of the qry type like the code on the next line?

List<QRY_HOSTING_Relaty> relatieLijst = (
    from QRY_HOSTING_Relaty res 
    in dcRelaties.QRY_HOSTING_Relaties
    select res).ToList<QRY_HOSTING_Relaty>();

It's that i'm not sure if I have to make my own types while i already have types defined by my dbml's which i probably just can use. so, should i implement my own Relations class and make use of the dbml's?

+1  A: 

You should typically have 1 single DBML file per database / domain. You should not create a DBML per table / class / entity, because this will create one DataContext per class. Doing this would make you lose most of the useful capabilities of LINQ to SQL, like memory transactions (unit of work) and doing LINQ queries over multiple entities.

It is normally not needed to create your own types that wrap the classes that are generated by LINQ to SQL. The typical usage is to: create tables (with proper relationships) in your database; Create a DBML and drag all needed tables on the DBML; Change table and column names were appropriate.

Steven
Very much appreciated ;)!
Younes