其他分享
首页 > 其他分享> > 基于EF的外键的查询 使用【ForeignKey(“ SupplierId”】特性

基于EF的外键的查询 使用【ForeignKey(“ SupplierId”】特性

作者:互联网

  //实体模型类:
        /// 供应商id
        /// </summary>
        public Guid? SupplierId { get; set; }
        /// <summary>
        /// SupplierId—是该表的外键 是DB_Supplier表的主键
        /// DB_Supplier 表名
        /// </summary>
        [ForeignKey("SupplierId")]
        public virtual DB_Supplier Supplier { get; set; }
  var list = WMFactory.FMCostBillService.FindByPage(start, length, out totalCount, x => x.OrderByDescending(a => a.CreateTime), null, condition).Select(a => new
            {
                Id = a.Id,
                BillTag = a.BillTag,
                Code = a.Code,
                PdtCodes = a.PdtCodes,
                BillDate = a.BillDate,
                FollowMan = a.FollowMan,
                SrcType = a.SrcType,
                SrcOrderCode = a.SrcOrderCode,
                Supplier = new {
                    Name = a.Supplier.SpName,
                },
                SpBrank=a.SpBrank,
                SpTaxNo=a.SpTaxNo,
                SpBrankMan=a.SpBrankMan,
                SpBrankAccount=a.SpBrankAccount,
                SpAddrTel=a.SpAddrTel,
                ApplyMey=a.ApplyMey,
                PaidMey=a.PaidMey,
                IsDebt=a.IsDebt,
                IsCutDown=a.IsCutDown,
                PayType=a.PayType,
                FicType=a.FicType,
                InvoiceNumber=a.InvoiceNumber,
                Remark=a.Remark,
                CreateUser=a.CreateUser,
                CreateTime=a.CreateTime
            });

客户端 使用时 直接对象点属性  比如 “  { "title": "供应商", "data": "Supplier.Name" },”

 

标签:IsDebt,set,SupplierId,ForeignKey,EF,DB,Supplier,CreateTime
来源: https://www.cnblogs.com/cloudcmm/p/10776768.html