随笔分类 -  ef

摘要:ef/efcore: 以datatype字段分组后按count倒序: var list=db.table1.GroupBy(x => x.DataType).Select(group=>new { group.Key,Count=group.Count()}).OrderByDescending(x 阅读全文
posted @ 2023-05-30 15:52 Ace001 阅读(613) 评论(0) 推荐(0)
摘要:F12转到DBContext 在同级目录下新建同名的class 注意partial关键字 然后修改系统生成的dbcontext类的构造函数,改为使用解析后的链接字符串传入 阅读全文
posted @ 2021-05-14 11:33 Ace001 阅读(272) 评论(1) 推荐(0)
摘要:1.使用entityConnectionStringBuilder 创建连接字符串 public static string GetConnStr(string host, string catalog, string user, string pass, bool winAuth=false) { 阅读全文
posted @ 2020-01-10 13:38 Ace001 阅读(1976) 评论(0) 推荐(0)
摘要:https://blog.csdn.net/weixin_34321977/article/details/85850064 在使用 EF 的时候,突然发现更新后在服务器中运行出错,异常信息主要包含以下信息: 想到可能时因为本地开发环境的数据库版本高于服务器版本,导致 EF 生成了错误的 SQL 语 阅读全文
posted @ 2019-05-09 15:13 Ace001 阅读(1577) 评论(0) 推荐(0)
摘要:1.linqtosql查看sql var dc=new DBDataContext(); TextWriter tw = new StringWriter(); dc.Log = tw; var list = dc.News.Skip((page - 1) * limit).Take(limit). 阅读全文
posted @ 2018-04-24 09:18 Ace001 阅读(1119) 评论(1) 推荐(1)
摘要:1.安装 mysql connector net 6.9.9 https://dev.mysql.com/downloads/file/?id=463758 和mysql for visual studio 1.2.6 2.nuget安装 Install-Package MySql.Data.Ent 阅读全文
posted @ 2017-05-26 11:25 Ace001 阅读(812) 评论(0) 推荐(0)
摘要:类型 xx 的成员 xxx 是接口,因此无法将其序列化。 修改.tt模板文件,添加以下标红两行 <# foreach (var navigationProperty in navigationProperties) { #> [Newtonsoft.Json.JsonIgnore] [System. 阅读全文
posted @ 2017-05-02 10:29 Ace001 阅读(1152) 评论(1) 推荐(1)