• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
 






java小兵

 
 

Powered by 博客园
博客园 | 首页 | 新随笔 | 联系 | 订阅 订阅 | 管理
上一页 1 2 3 4 5 6 7 ··· 12 下一页

2022年2月2日

dotnetcore EF 小技巧(但不推荐)
摘要: 正常情况下,都是通过EF先取出entity,再修改或删除。 这样会生成一条select和一条update或delete语句,但是通过update/delete sql可以一句就完成。 使用以下代码,通过欺骗EF的方式,使得一句sql完成目标。 using (MyDbContext ctx = new 阅读全文
posted @ 2022-02-02 20:07 .net一小兵 阅读(59) 评论(0) 推荐(0)
 
dotnetcore EF 获取Entity状态
摘要: 通过EntityEntry可以获取Entity状态 using Microsoft.EntityFrameworkCore.ChangeTracking; static async Task Main(string[] args) { using (MyDbContext ctx = new MyD 阅读全文
posted @ 2022-02-02 19:20 .net一小兵 阅读(87) 评论(0) 推荐(0)
 

2022年2月1日

dotnetcore EF 非原生sql调用
摘要: 尽量使用EF的异步调用 await ctx.Students.ToListAsync() await foreach (var s in ctx.Students.AsAsyncEnumerable()) FormattableString使用 int a = 111; string world = 阅读全文
posted @ 2022-02-01 19:38 .net一小兵 阅读(296) 评论(0) 推荐(0)
 

2022年1月31日

dotnetcore EF 分页
摘要: 保存100个students,有意思的是虽然看似所有的students应该有序插入,但是db显示students的顺序是乱的。 // 保存100个students,有意思的是虽然看似所有的students应该有序插入,但是db显示students的顺序是乱的。 private static asyn 阅读全文
posted @ 2022-01-31 18:29 .net一小兵 阅读(130) 评论(0) 推荐(0)
 

2022年1月30日

dotnetcore EF many-to-many mapping
摘要: class Student { public int Id { get; set; } public string Name { get; set; } public List<Teacher> Teachers { get; } = new List<Teacher>(); } class Stu 阅读全文
posted @ 2022-01-30 18:14 .net一小兵 阅读(41) 评论(0) 推荐(0)
 
dotnetcore EF one-to-one mapping
摘要: class Delivery { public int Id { get; set; } public string CompanyName { get; set; } public string Number { get; set; } public Order Order { get; set; 阅读全文
posted @ 2022-01-30 17:33 .net一小兵 阅读(60) 评论(0) 推荐(0)
 
dotnetcore EF 使用自引用实体
摘要: class OrgUnit { public int Id { get; set; } public string Name { get; set; } public OrgUnit Parent { get; set; } public List<OrgUnit> Children { get; 阅读全文
posted @ 2022-01-30 14:55 .net一小兵 阅读(125) 评论(0) 推荐(0)
 

2022年1月29日

dotnetcore EF 使用外键值但不引入join子句
摘要: 某些情况下,出于性能考虑,我们需要外键的id值,但不想使用join子句把引用类型都读进来。 class Book { public int Id { get; set; } public string Name { get; set; } public string Author { get; se 阅读全文
posted @ 2022-01-29 18:52 .net一小兵 阅读(55) 评论(0) 推荐(0)
 
dotnetcore EF one-to-many mapping
摘要: class Person { public int Id { get; set; } public string Name { get; set; } public int Age { get; set; } public DateTime Birthday { get; set; } public 阅读全文
posted @ 2022-01-29 10:42 .net一小兵 阅读(39) 评论(0) 推荐(0)
 
dotnetcore EF migration
摘要: migration命令需要安装Microsoft.EntityFrameworkCore.Tools dotnet add package Microsoft.EntityFrameworkCore.sqlserver --version 5.0.13 dotnet add package Micr 阅读全文
posted @ 2022-01-29 09:27 .net一小兵 阅读(116) 评论(0) 推荐(0)
 
上一页 1 2 3 4 5 6 7 ··· 12 下一页