对于网站建设的体会网站策划需求

当前位置: 首页 > news >正文

对于网站建设的体会,网站策划需求,wordpress 幻灯片 视频,注册公司一般多少费用.NET开源 ORM 框架 SqlSugar 系列 【开篇】.NET开源 ORM 框架 SqlSugar 系列【入门必看】.NET开源 ORM 框架 SqlSugar 系列【实体配置】.NET开源 ORM 框架 SqlSugar 系列【Db First】.NET开源 ORM 框架 SqlSugar 系列【Code First】.NET开源 ORM 框架 SqlSugar 系列【数据事务… .NET开源 ORM 框架 SqlSugar 系列 【开篇】.NET开源 ORM 框架 SqlSugar 系列【入门必看】.NET开源 ORM 框架 SqlSugar 系列【实体配置】.NET开源 ORM 框架 SqlSugar 系列【Db First】.NET开源 ORM 框架 SqlSugar 系列【Code First】.NET开源 ORM 框架 SqlSugar 系列【数据事务】.NET开源 ORM 框架 SqlSugar 系列【连接池】.NET开源 ORM 框架 SqlSugar 系列【查询目录】.NET开源 ORM 框架 SqlSugar 系列【查询基础】.NET开源 ORM 框架 SqlSugar 系列【排序用法】.NET开源 ORM 框架 SqlSugar 系列【分组去重】.NET开源 ORM 框架 SqlSugar 系列【联表查询】.NET开源 ORM 框架 SqlSugar 系列【导航查询】.NET开源 ORM 框架 SqlSugar 系列【子查询】.NET开源 ORM 框架 SqlSugar 系列【嵌套查询】.NET开源 ORM 框架 SqlSugar 系列【配置查询】.NET开源 ORM 框架 SqlSugar 系列【并集查询】.NET开源 ORM 框架 SqlSugar 系列 一、抛砖引玉 1、实际开发中数据库大量用到 多表查询 只为一个字段就进行 联表 。 2、字典表 的 联表查询 字典表我相信大家都全用到他们可以方便的存储性别、学历、岗位等 一串数据 并进行TypeId进行区分 二、应对策略 2.1 字典导航 通过导航查询我们也可以实现配置查询 ✅优点支持多层级 一对一  。 不足:  像字典表那样 没办法 动态配置 依赖主键 和 导航配置 。 public class DataMain {//表属性 public int Id{get;set;}public string Name{get;set;}public string SexCode { get; set; }public string Province { get; set; }//导航[SqlSugar.Navigate(NavigateType.OneToOne,nameof(SexCode),nameof(DataDictionary1.Code),typesex)]public DataDictionary1 SexInfo { get; set; }[SqlSugar.Navigate(NavigateType.OneToOne, nameof(Province), nameof(DataDictionary1.Code), typeprovince)]public DataDictionary1 ProvinceInfo { get; set; } }var listdb.QueryableDataMain().Includes(x x.SexInfo).Includes(x x.ProvinceInfo).ToList();//返回导航属性//联表导航 var list2 db.QueryableDataMain().Where(xx.SexInfo.Name男)//也可以在Select用.ToList(); 2.2 传统配置查询 2.2.1 创建测试数据 创建一个字典实体 public class DataDictionary {public string Code { get; set; }public string Name { get; set; }public string Type { get; set; } } 创建字典表并向里面插入测试数据 var db GetInstance();ListDataDictionary datas new ListDataDictionary();datas.Add(new DataDictionary() { Code1, Name男,Typesex });datas.Add(new DataDictionary() { Code 2, Name 女, Type sex });datas.Add(new DataDictionary() { Code 1, Name 南通市, Type city });datas.Add(new DataDictionary() { Code 2, Name 苏州市, Type city });datas.Add(new DataDictionary() { Code 1, Name 江苏省, Type province });datas.Add(new DataDictionary() { Code 2, Name 湖南省, Type province });db.Insertable(datas).ExecuteCommand();//这样就能把数据插进数据库了 再建一个Person表 public class Person {//数据库字段[SqlSugar.SugarColumn(IsPrimaryKey true,IsIdentity true)]public int Id { get; set; }public string Name { get; set; }public int SexId { get; set; }public int CityId { get; set; }public int ProvinceId { get; set; }//非数据库字段[SqlSugar.SugarColumn(IsIgnore true)]public string SexName { get; set; }[SqlSugar.SugarColumn(IsIgnore true)]public string CityName { get; set; }[SqlSugar.SugarColumn(IsIgnore true)]public string ProvinceName { get; set; } }  2.2.2 传统实现缺点 如果我们要将 Person 中的非数据字段查询出来那么我们就需要写有 2种 实现方式 连表或者子查询 缺点 写起来很浪费时间 将字典存到内存通过内存赋值 缺点 字典表 超过1000 条以上 性能很差  并且 不能排序 或者 LIKE
2.2.3 使用配置查询 配置字典表 //保证程序启动后只执行一次lock(单例对象) { var types db.QueryableDataDictionary().Select(it it.Type).Distinct().ToList();foreach (var type in types){db.ConfigQuery.SetTableDataDictionary(it it.Code,it it.Name,type,it it.Typetype);}}//像姓别是01 02 学历也是01 02 这种只能按这种循环方式需要加个Type区分唯一//如果其中Code都是唯一值可以按1.4中的用法使用 一行代码就可以配置不需要循环//如果你认为麻烦你也可以把这个配置扔到程序启动中完成 配置完我们查询就会很方便了 var resdb.QueryablePerson().Select(it new Person(){Idit.Id.SelectAll(), // Oracle 注意单表查询要设置别名SelectAll(别名)SexNameit.SexId.GetConfigValueDataDictionary(sex),ProvinceName it.ProvinceId.GetConfigValueDataDictionary(province),CityName it.CityId.GetConfigValueDataDictionary(city),}).ToList();//生成的Sql//select *,// (select name from DataDictionary where typesex where t.codesexid) as sexname,// (select name from DataDictionary where typecitywhere t.codecityid) as cityname, // (select name from DataDictionary where typeprovince where t.codeprovinceid) as provincename // from Person t //支持写在Where或者Orderby  2.2.4 简单联表查询配置 //配置Order if (!db.ConfigQuery.Any()) //保证只配置一次不能更新,该配置是全局静态存储 {db.ConfigQuery.SetTableOrder(it it.Id, it it.Name);//多个配置可以一起写在下面 } //使用 var list3 db.QueryableOrderItem().Select(it new OrderItem {ItemId it.ItemId.SelectAll(), // Oracle 注意单表查询要设置别名SelectAll(别名)OrderName it.OrderId.GetConfigValueOrder() //查询的时候直接用 }).ToList(); //select *, // (select name from order where id t.orderid) as ordername //from orderitem t 总结配置表查询的方式可以大大降低重复联表问题并且配置好后基本就不要写JOIN了。 2.2.5 参数介绍 SetTableT 总共4个参数 ,T 代表哪个实体表 参数 1、主键或者关联字段 参数 2、显示的文本 参数 3、唯一标识可不填 当一个T对应多个查询的时候需要指定一个唯一标识 参数 4、查询条件可不填 万丈高楼平地起做开发想要技术精进必须要有扎实的基础功底。基础SQL查询语法一定要牢记于心才能应对后面更为复杂的形势。 .NET开源 ORM 框架 SqlSugar 系列 【开篇】.NET开源 ORM 框架 SqlSugar 系列【入门必看】.NET开源 ORM 框架 SqlSugar 系列【实体配置】.NET开源 ORM 框架 SqlSugar 系列【Db First】.NET开源 ORM 框架 SqlSugar 系列【Code First】.NET开源 ORM 框架 SqlSugar 系列【数据事务】.NET开源 ORM 框架 SqlSugar 系列【连接池】.NET开源 ORM 框架 SqlSugar 系列【查询目录】.NET开源 ORM 框架 SqlSugar 系列【查询基础】.NET开源 ORM 框架 SqlSugar 系列【排序用法】.NET开源 ORM 框架 SqlSugar 系列【分组去重】.NET开源 ORM 框架 SqlSugar 系列【联表查询】.NET开源 ORM 框架 SqlSugar 系列【导航查询】.NET开源 ORM 框架 SqlSugar 系列【子查询】.NET开源 ORM 框架 SqlSugar 系列【嵌套查询】.NET开源 ORM 框架 SqlSugar 系列【配置查询】.NET开源 ORM 框架 SqlSugar 系列【并集查询】.NET开源 ORM 框架 SqlSugar 系列