When choosing an ORM, is LINQ to SQL or LINQ to Entities better than NHibernate?

后端 未结 6 1368
萌比男神i
萌比男神i 2021-01-02 19:05

I find I can do more with NHibernate, and even Castle than with the Linq to Entities, or linq to SQL.

Am I crazy?

6条回答
  •  醉话见心
    2021-01-02 19:18

    I have not tried the Entity Framework, but I definitely would recommend NHibernate over Linq to SQL; The biggest reason I can give is just the control. Linq to SQL likes to have a lot more control over everything, loading the object and maintaining all kinds of tracking information about the object. If you serialize/deserialize, the tracking information can be lost and strange things can happen when saving it again. NHibernate works more as a repository should - You hand it whatever object you want (that you have configured it to understand, of course), and it puts it away in the database, regardless of what you've done with it.

提交回复
热议问题