lmsasu
lmsasu

Reputation: 7583

LINQ to SQL as Unit of Work

From your experience, is LINQ to SQL appropriate as a Unit of Work? is it avoidable? should I prefer, say, NHibernate or another O/RM tool?

Thanks, Lucian

Upvotes: 4

Views: 1916

Answers (1)

ChadT
ChadT

Reputation: 7713

The Linq to Sql data context is designed to be used for a single unit of work.

Edit: to add references.

The Linq To SQL FAQ:

Q: Should I create a new DataContext in every business logic method?

A: The DataContext conforms to the Unit of Work design pattern. Unless you are moving data between physical tiers between each operation you should keep your DataContext alive for the duration of work.

Upvotes: 4

Related Questions