What are the best practices for developing the class library as a whole and the database level?

I am going to create a database layer to expose a set of functions that will provide reading and writing to our database. I have many questions related to this, and I want someone to advise

  • How can I handle database exceptions (e.g. timeout exceptions) or leave the dll client to handle them

  • The dll will not be thread safe, so should I use one connection for the dll instance? as it improves productivity.

  • Are there general rules for developing a class library?

I am using C # vs2008 and SQL2008

+5
source share
2 answers

1: ; , , , , ( , )

2: "" , ; . , , ( , ), , .. ( )

3: , ; ORM, LINQ-to-SQL, Entity Framework, NHibernate ..

.

Customer GetCustomer(int id) {
    using(var conn = CreateConnection()) {
        conn.Open();
        // etc
    }
}
+5

, , , , , . , , , , ?

, db, , , , , , , . , .

Linq to SQL, , -, ADO.net ORM .

+3

All Articles