Lightweight alternatives to NHibernate

后端 未结 8 1935
感情败类
感情败类 2021-01-01 17:54

NHibernate is not really a good fit for our environment due to all the dependencies. (Castle, log4net etc.)

Is there a good lightweight alternative?

Support

8条回答
  •  爱一瞬间的悲伤
    2021-01-01 18:05

    If you don't need fully-functional ORM and just need fast database independent data layer over ADO.NET try out open-source NI.Data library (V2). It is very lightweight (just one small assembly, no other dependencies), provides all standard data layer infrastructure:

    • query abstraction and parser for its string representation called 'relex' (it looks like: "books(rating=5)[title,id]" - very good alternative to Linq-to-SQL and expressions can be composed on the fly )
    • 'view' concept for encapsulating complex DB-syntax dependent SQL queries
    • data triggers
    • data layer permissions for select/update/delete queries
    • from the box supports MS SQL, SQLite, MySQL, Odbc/OleDb providers (MS Access). Support for other SQL databases could be easily added.

    Its main component (DALC) initialized just with one line of code:

    var dalc = new DbDalc(new SqlClientDalcFactory(), connectionStr);
    

    that's all. If you need .NET 2.0 runtime support you can try to compile either latest V2 version under 2.0 runtime or use previous legacy version (NI.Data.Dalc, V1).

提交回复
热议问题