1

Is it a bad idea to use linq to sql as my data-layer to retrieve data, and then populate the data into my business layer?

Am i going to be facing performance problems?

What is the most efficient way of getting data from database and populating it into my business objects?

2 Answers 2

3

Linq to Sql will give you good enough performance for all but the most demanding applications. If you are only ever considering using a SQL Server database, Linq to SQL is a very productive ORM to work with, and it "just works".

I used to use Linq to SQL on all .NET apps I developed on SQL Server. Then I discovered the simplicity and elegance of Entity Framework (4.1) and the Code First approach. This approach works nicely with Domain Driven Design, while allowing you to write business objects without writing any persistance code at all, by means of a convention based approach. Worth thinking about.

Sign up to request clarification or add additional context in comments.

Comments

2

If you don't do anything stupid LINQ2SQL won't give you big performance problems. There is a small overhead using LINQ2SQL but that is quite small.

The most efficient way would be to select straight into your business objects in the select part.

var myResult = from product in context.Products
               where product.StockQty > 10
               select new MyBusinessProduct
               {
                   Name = product.Name,
                   Category = product.Category,
                   etc = product.etc, //...
               }

Often you can use your LINQ-objects as your business objects, you can decorate them with your business methods in a partial class and also implement the partial methods on the LINQ classes to implement validation rules.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.