0

NOTE: I am not an expert, so if you feel this question stupid/lame please forgive and mind your business. :)

Ok, as all video tutorials tell, create a LinqToSqlClasses item (dbml) file. drag tables and we are done here.

But in my case (or probably in all real world scenarios), we need more from our Data Access Layer than just the auto generated classes, right?

For Example: In a simple accounting software: i have a Accounts Table and a AccountingTransactions Table,

Now to get any account's ledger we need to write a pretty Lengthy sql query, same goes for trial-balance, day book, and Single Vouchers et cetera.

What can we do in DAL to optimize these queries to have best performance.

Asad Malik
  • 763
  • 2
  • 8
  • 24

1 Answers1

1

I would recommend using Entity Framework over Linq to SQL.

But in both these cases, you have the power of Linq for such queries. Plus this gives you better designer support (intellisense, strong types, compile time checking)

EF or LinqToSQL becomes the lower level DAL and on top of this you would use the Repository pattern to call your Data Objects in a loosely coupled way. You could also add special methods for certain repositories to query data in a specific way if this needs to be encapsulated.

You should search SO for the repository pattern with Entity Framework or LinqToSql, you'll find a couple of implementations.

See this answer : Advantage of creating a generic repository vs. specific repository for each object?

Community
  • 1
  • 1
gideon
  • 19,329
  • 11
  • 72
  • 113