Is there a "Fluent Linq To Entites" that I can开发者_如何学C use to Setup my dataContext without having to map anything through diagram files?
All I need is to map my db tables to certain domain classes without any need for Lazy-Loading. I tried using LinqToSql but it was a No-Go since my domain classes all inherit from base classes.
Note: We can only use .NET 3.5
If you can get away from using Entity Framework, you could use Fluent NHibernate + AutoMapping. http://wiki.fluentnhibernate.org/Auto_mapping
Or you could use Linq 2 SQL by decorating your entity with attributes.
Like:
[Table(Name="Product")]
public class Product
{
[Column(IsPrimaryKey=true, IsDbGenerated=true, AutoSync=AutoSync.OnInsert]
internal int Id {get;set;}
[Column]
public string Name {get;set;}
}
Then access it using the dbcontext like:
ctx.GetTable<Product>().SingleOrDefault(x=>x.Id == 1);
Along those lines, wrote that off top of my head but you get the gist.
I would go Fluent+AutoMapping.
There has recently been a CTP release of Entity Framework that provides support for a "Code First" or "Code Only" style of development. I believe those libraries will allow you to setup your context without a map. However, I don't think that there is anything currently released for Entity Framework which will do what you're looking for.
精彩评论