using SqlSugar; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace OrmTest { public class UIncludesadfadfaf { public static void Init() { Console.WriteLine(""); Console.WriteLine("#### SqlQueryable Start ####"); var db = NewUnitTest.Db; //by sql //db.CodeFirst.InitTables(); //db.CodeFirst.InitTables(); var list3 = db.Queryable().Where(t => t.ProductPartSNs.Any(n => n.PartSN.SN == "WEB2022052614050")).ToList(); //db.InitMappingInfo(); var list4 = db.Queryable().Where(t => t.ProductPartSNs.Any(n => n.PartSNID == "WEB2022052614050")).ToList(); Console.WriteLine("#### SqlQueryable End ####"); } } [Tenant("MesConfig")] [SugarTable("TB_PRODUCT", TableDescription = "产品信息")] public partial class ProductEntity { /// /// 产品信息(构建函数) /// public ProductEntity() { this.KeyID = Guid.NewGuid().ToString(); this.CreatorTime = DateTime.Now; this.CurrentIndex = 0; this.EnabledMark = true; } #region 实体成员 /// /// 主键 /// [SugarColumn(IsPrimaryKey = true, ColumnName = "F_Id")] public string KeyID { get; set; } /// /// 创建人编号 /// [SugarColumn(ColumnName = "F_CREATORUSERID")] public string CreatorUserId { get; set; } /// /// 创建时间 /// [SugarColumn(ColumnName = "F_CREATORTIME")] public DateTime? CreatorTime { get; set; } /// /// 修改人 /// [SugarColumn(ColumnName = "F_LASTMODIFYUSERID")] public String LastModifyUserId { get; set; } /// /// 修改时间 /// [SugarColumn(ColumnName = "F_LASTMODIFYTIME")] public DateTime? LastModifyTime { get; set; } /// /// 删除时间 /// [SugarColumn(ColumnName = "F_DELETETIME")] public DateTime? DeleteTime { get; set; } /// /// 删除人员ID /// [SugarColumn(ColumnName = "F_DELETEUSERID")] public string DeleteUserId { get; set; } /// /// 产品关联产品信息 /// [SugarColumn(ColumnName = "ProductPartSNs", IsIgnore = true)] [Navigate(NavigateType.OneToMany, nameof(ProductPartSNEntity.ProductID))] public List ProductPartSNs { get; set; } /// /// 条码显示 /// [SugarColumn(ColumnName = "C_SNSHOW")] public string SnShow { get; set; } /// /// 条码个数 /// [SugarColumn(ColumnName = "C_SNCOUNT")] public int? SnCount { get; set; } /// /// 产品型号ID /// [SugarColumn(ColumnName = "C_PRODUCTTYPEID")] public string ProductTypeID { get; set; } ///// ///// 产品类型信息 ///// //[SugarColumn(ColumnName = "ProductType", IsIgnore = true)] //[Navigate(NavigateType.OneToOne, nameof(ProductTypeID))] //public ProductTypeEntity ProductType { get; set; } /// /// 当前在进行第几次存储 /// [SugarColumn(ColumnName = "C_CURRENTINDEX")] public int? CurrentIndex { get; set; } /// /// 是否可用 /// [SugarColumn(ColumnName = "ENABLEDMARK")] public bool? EnabledMark { get; set; } /// /// 返修工单ID /// [SugarColumn(ColumnName = "C_REPAIRWORKID")] public string RepairWorkID { get; set; } #endregion } /// /// 产品配置条码表 /// [Tenant("MesConfig")] [SugarTable("TC_PRODUCTPARTSN", TableDescription = "产品配置条码表")] public partial class ProductPartSNEntity { #region 实体成员 /// /// 主键 /// [SugarColumn(IsPrimaryKey = true, ColumnName = "F_Id")] public string KeyID { get; set; } /// /// 创建人编号 /// [SugarColumn(ColumnName = "F_CREATORUSERID")] public string CreatorUserId { get; set; } /// /// 创建时间 /// [SugarColumn(ColumnName = "F_CREATORTIME")] public DateTime? CreatorTime { get; set; } /// /// 修改人 /// [SugarColumn(ColumnName = "F_LASTMODIFYUSERID")] public String LastModifyUserId { get; set; } /// /// 修改时间 /// [SugarColumn(ColumnName = "F_LASTMODIFYTIME")] public DateTime? LastModifyTime { get; set; } /// /// 删除时间 /// [SugarColumn(ColumnName = "F_DELETETIME")] public DateTime? DeleteTime { get; set; } /// /// 删除人员ID /// [SugarColumn(ColumnName = "F_DELETEUSERID")] public string DeleteUserId { get; set; } /// /// 产品ID /// [SugarColumn(ColumnName = "C_PRODUCTID")] public string ProductID { get; set; } /// /// 配件条码ID /// [SugarColumn(ColumnName = "C_PARTSNID")] public string PartSNID { get; set; } /// /// 配件条码ID /// [SugarColumn(ColumnName = "PARTSN", IsIgnore = true)] [Navigate(NavigateType.OneToOne, nameof(PartSNID))] public PartSNEntity PartSN { get; set; } /// /// 配件类型 /// [SugarColumn(ColumnName = "C_ISMAINSN")] public PartSNType IsMainSN { get; set; } #endregion } /// /// 构成类型 /// public enum PartSNType { /// /// 配件码 /// PartSN = 0, /// /// 主码 /// MainSN = 1, /// /// 产品码 /// ProductSN = 2, } /// /// 产品条码信息 /// [Tenant("MesConfig")] [SugarTable("TB_PARTSN", TableDescription = "配件条码信息")] public partial class PartSNEntity { public PartSNEntity() { this.KeyID = Guid.NewGuid().ToString(); this.CreatorTime = DateTime.Now; } #region 实体成员 /// /// 主键 /// [SugarColumn(IsPrimaryKey = true, ColumnName = "F_Id")] public string KeyID { get; set; } /// /// 创建人编号 /// [SugarColumn(ColumnName = "F_CREATORUSERID")] public string CreatorUserId { get; set; } /// /// 创建时间 /// [SugarColumn(ColumnName = "F_CREATORTIME")] public DateTime? CreatorTime { get; set; } /// /// 修改人 /// [SugarColumn(ColumnName = "F_LASTMODIFYUSERID")] public String LastModifyUserId { get; set; } /// /// 修改时间 /// [SugarColumn(ColumnName = "F_LASTMODIFYTIME")] public DateTime? LastModifyTime { get; set; } /// /// 删除时间 /// [SugarColumn(ColumnName = "F_DELETETIME")] public DateTime? DeleteTime { get; set; } /// /// 删除人员ID /// [SugarColumn(ColumnName = "F_DELETEUSERID")] public string DeleteUserId { get; set; } /// /// 配件ID /// [SugarColumn(ColumnName = "C_PARTID")] public String PartID { get; set; } /// /// 配件 /// [SugarColumn(ColumnName = "PART", IsIgnore = true)] [Navigate(NavigateType.OneToOne, nameof(PartID))] public PartEntity Part { get; set; } /// /// 条码 /// [SugarColumn(ColumnName = "C_SN")] public string SN { get; set; } /// /// 使用次数统计 /// [SugarColumn(ColumnName = "C_USECOUNT")] public int UseCount { get; set; } /// /// 是否可用 /// [SugarColumn(ColumnName = "ENABLEDMARK")] public bool? EnabledMark { get; set; } = true; #endregion #region 扩展操作 #endregion } /// /// 配件信息 /// [Tenant("MesConfig")] [SugarTable("TB_PART", TableDescription = "配件表")] public partial class PartEntity { #region 实体成员 /// /// 主键 /// [SugarColumn(IsPrimaryKey = true, ColumnName = "F_Id")] public string KeyID { get; set; } /// /// 创建人编号 /// [SugarColumn(ColumnName = "F_CREATORUSERID")] public string CreatorUserId { get; set; } /// /// 创建时间 /// [SugarColumn(ColumnName = "F_CREATORTIME")] public DateTime? CreatorTime { get; set; } /// /// 修改人 /// [SugarColumn(ColumnName = "F_LASTMODIFYUSERID")] public String LastModifyUserId { get; set; } /// /// 修改时间 /// [SugarColumn(ColumnName = "F_LASTMODIFYTIME")] public DateTime? LastModifyTime { get; set; } /// /// 删除时间 /// [SugarColumn(ColumnName = "F_DELETETIME")] public DateTime? DeleteTime { get; set; } /// /// 删除人员ID /// [SugarColumn(ColumnName = "F_DELETEUSERID")] public string DeleteUserId { get; set; } /// /// 配件名称 /// [SugarColumn(ColumnName = "C_PARTNAME")] public string PartName { get; set; } /// /// 注释 /// [SugarColumn(ColumnName = "C_DESC")] public string Desc { get; set; } /// /// 是否可用 /// [SugarColumn(ColumnName = "ENABLEDMARK")] public bool? EnabledMark { get; set; } #endregion } }