随笔分类 - ORM
摘要:1.DbContext怎么在Asp.mvc中使用? 这么定义之后,所有需要用到DbContext对象的地方,都调这个方法。 2. 不要随便using或Dispose DbContext会导致延迟加载的不可用,还会有一些其他错误 如IQueryable<T> 下面的方法(.First() /.Coun
阅读全文
摘要:更准确的说法是EF对比SqlHelper ado.net public class SqlHelper { public static readonly string connstr = "Server=.;Database=PhoneBook;Uid=sa;Pwd=********;"; //pa
阅读全文
摘要:EF和SqlHelper 简单三层 EF生成sql,再调用ado.net访问数据库,最后使结果对象具体化. 之前的SqlHelper 简单三层的写法,拼接sql语句字符串,再调用ado.net访问数据库,最后也是把结果转换为对象. 明显的区别:sql语句的产生,EF是SQL查询命令和 LINQ 查询
阅读全文
摘要:前面提到过这个网址:性能注意事项(实体框架) https://msdn.microsoft.com/zh-cn/library/cc853327.aspx注意版本: .NET Framework (current version) (还有一个其他版本, .NET Framework 4). 此文提到
阅读全文
摘要:继续上篇:EntityFramework和EntityFramework.Extended使用说明——性能,语法和产生的sql 1.监控sql 上篇中的sql监控采用的是 Microsoft SQL Server Management Studio中工具->profiler去监控的.当然,Expre
阅读全文
摘要:环境说明:EntityFramework 6.1.3和.Net Framework4.5性能注意事项:https://msdn.microsoft.com/zh-cn/library/cc853327.aspx比较精髓的一点:查询执行的各个阶段中的准备查询,每个唯一查询一次。包括编写查询命令、基于模
阅读全文
摘要:using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Simple.Data; namespace SimpleDataStudy { class Program { sta...
阅读全文
摘要:using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Text; using System.Threading.Tasks; using Dapper; namespace DapperTest...
阅读全文