NOLOCK with Linq to SQL

Yes it is, so here’s the entry from my blog: The NOLOCK hint is essentially the same as wrapping a query in a transaction whose “isolation level” is set to “read uncommitted”. It means that the query doesn’t care if stuff is in the process of being written to the rows it’s reading from – … Read more

ASP.MVC: Repository that reflects IQueryable but not Linq to SQL, DDD How To question

Assuming that your LINQ to SQL (L2S) classes are auto-generated and reflects your underlying database, the short answer is: Don’t expose IQueryable of any of your L2S classes – it would be a Leaky Abstraction. The slightly longer answer: The whole point of Repositories is to hide data access behind an abstraction so that you … Read more

C# Linq-to-Sql – Should DataContext be disposed using IDisposable

Unlike most types which implement IDisposable, DataContext doesn’t really need disposing – at least not in most cases. I asked Matt Warren about this design decision, and here was his response: There are a few reasons we implemented IDisposable: If application logic needs to hold onto an entity beyond when the DataContext is expected to … Read more

Benchmark Linq2SQL, Subsonic2, Subsonic3 – Any other ideas to make them faster?

Aristos, here’s the thing I’m having an issue with. You posted a question to our groups and we had a nice, 23-long email exchange. You insisted that SubSonic 3 has problems and you asked me why I haven’t fixed this “slow, broken tool”. I tried to explain to you that, with 233 tables, SubSonic has … Read more

How to do a join in linq to sql with method syntax?

var result = from sc in enumerableOfSomeClass join soc in enumerableOfSomeOtherClass on sc.Property1 equals soc.Property2 select new { SomeClass = sc, SomeOtherClass = soc }; Would be equivalent to: var result = enumerableOfSomeClass .Join(enumerableOfSomeOtherClass, sc => sc.Property1, soc => soc.Property2, (sc, soc) => new { SomeClass = sc, SomeOtherClass = soc }); As you can … Read more

Does AutoMapper support Linq?

While @Aaronaught’s answer was correct at the time of writing, as often the world has changed and AutoMapper with it. In the mean time, QueryableExtensions were added to the code base which added support for projections that get translated into expressions and, finally, SQL. The core extension method is ProjectTo1. This is what your code … Read more

Is LINQ to SQL Dead or Alive?

1) They can’t “kill” Linq-to-SQL as it is already part of the .net framework. What they can do is stop adding features to it. That doesn’t prevent the thousands of developers out there that are already using L2S from extending it and improving it. Some core areas are tricky to touch but they’re solid already … Read more