0

I'm trying to design application that will have UI with database in the backend.

I will be using Linq-to-SQL as the database layer to update and insert.

Now I'm trying to find out the best practice to use in designing the project, suppose I have 2 tables in the DB (Customers, Orders)

  1. Shall I depend on the generated Linq-to-SQL classes, or shall I still create classes for Customers, Orders?

  2. Shall I wrap the generated Linq-to-SQL inside another class to add validations?

I hope my questions are clear.

2 Answers 2

1

L2S is in my opinion an excellent light-weight data access method. If you have control over the database and have limited application data processing logic it is often a good choice.

  1. If you have a two-tier app with a UI communicating directly with the DB then you can depend on the L2S generated classes. If you have a multi tier app with a client communicating with e.g. a WCF service you probably need Data Transfer Objects.

  2. Use the partial methods on the L2S classes for validation.

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

Comments

1

I think you should use other ORMs for better implementation DAL for example Entity Framework or Nhibernate this ORMs allow you Model First approach without attributes and the validation logic you should separate in other classes for exmaple MyEntityValidator And also good approach to use the Repository pattern this pattern allow doesn't depend on Data access EF or Nhibernate

and look at this Entity Framework and Repository

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.