IIRC, unless you'd want to use your db layer without LINQ query comprehensions (using the repository pattern), you should take a look at LINQ to NHibernate; in that case, you'd pretty much code against IQueryable<T>
results, which should translate most of the time. (Though you should really test this upfront, because every provider is different in its LINQ support.)
However, 1-* relations on your entity types will probably not share the same type by default (it's usually EntitySet<T>
in LINQ-to-SQL, and IList<T>
in NHibernate), but if you can force both LINQ-to-SQL and NHibernate to use IList<T>
or IEnumerable<T>
for such relations, this should work as well.
If you're only after compile time compatibility, the distinction between the various collection types should not be much of a problem, as long as you stick to the generic ones. For instance, if your NHibernate mapping uses IList<T>
and LINQ-to-SQL uses EntitySet<T>
, just stick to the IList<T>
methods, and you'll be safe.
Just watch out for lazy and eager loading differences of each framework.