EntityFramework 非常好用,结构优美.. 但是美中有不足.
1.对动态查询条件支持的不是很好
2.批量操作支持的不是很好.
下面就是几个第三方库,对EntityFramework 的扩展.具体如何使用请百度吧..
/**********************************************/
LinqKit(免费)
动态拼装查询条件
http://www.nuget.org/packages/LinqKit/
<code class="hljs mathematica has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">PM> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">Install</span>-Package LinqKit</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>
/**********************************************/
EFUtilities (免费)
优先推荐的.
1.功能包含单属性更新.
2.Delete by query
3.Batch insert entities
4.Batch update entities
5.Partial updates / Not loading the data from DB first
6.Update by query
…
如何使用看项目官网
https://github.com/MikaelEliasson/EntityFramework.Utilities
代码获取方式如下:
支持EF4和5
https://www.nuget.org/packages/EFUtilities/0.1.0
<code class="hljs mathematica has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">PM> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">Install</span>-Package EFUtilities -<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">Version</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.1</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.0</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>
支持EF6
https://www.nuget.org/packages/EFUtilities
<code class="hljs mathematica has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">PM> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">Install</span>-Package EFUtilities</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>
/**********************************************/
efbulkinsert(免费)
批量插入
http://efbulkinsert.codeplex.com/
<code class="hljs avrasm has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"> EF4 PM> Install-Package EntityFramework<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.BulkInsert</span>-ef4 <span class="hljs-label" style="box-sizing: border-box;">https:</span>//www<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.nuget</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.org</span>/packages/EntityFramework<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.BulkInsert</span>-ef4 EF5 PM> Install-Package EntityFramework<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.BulkInsert</span>-ef5 <span class="hljs-label" style="box-sizing: border-box;">https:</span>//www<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.nuget</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.org</span>/packages/EntityFramework<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.BulkInsert</span>-ef5 EF6 PM> Install-Package EntityFramework<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.BulkInsert</span>-ef6 <span class="hljs-label" style="box-sizing: border-box;">https:</span>//www<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.nuget</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.org</span>/packages/EntityFramework<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.BulkInsert</span>-ef6 </code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li><li style="box-sizing: border-box; padding: 0px 5px;">11</li><li style="box-sizing: border-box; padding: 0px 5px;">12</li><li style="box-sizing: border-box; padding: 0px 5px;">13</li><li style="box-sizing: border-box; padding: 0px 5px;">14</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li><li style="box-sizing: border-box; padding: 0px 5px;">11</li><li style="box-sizing: border-box; padding: 0px 5px;">12</li><li style="box-sizing: border-box; padding: 0px 5px;">13</li><li style="box-sizing: border-box; padding: 0px 5px;">14</li></ul>
/**********************************************/
EntityFramework.Extended (免费)
批量更新和删除,缓存
https://github.com/loresoft/EntityFramework.Extended
使用方法
<code class="hljs mathematica has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">PM> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">Install</span>-Package EntityFramework.Extended</code>