导航属性 跨服务器 跨库 返回

SqlSugar 待处理
2 240
该叫什么 发布于1个月前
悬赏:5 飞吻

导航属性 跨服务器 跨库  查询 异常

热忱回答2

  • 飞 VIP0
    1个月前
            
            //导航属性 CarType , AxleTypeInfo 同一类型 字典项  跨库 跨服务器    查询异常     都在   IndividualResoureces 表所在 库连接查询
            var query = await db.QueryableWithAttr<IndividualResoureces>()
                .Includes(c => c.CarType)
                .Includes(c => c.AxleTypeInfo)
                .With(SqlWith.NoLock)
                .Where(c => 
                c.State == 0
                &&c.VibrateState==1 
                && c.VibrateCode != null 
                && c.VibrateCode.Length >= 12)
            .Select(c => new
            {
                c.HeadLicense,  
                c.CarTypeID,
                NewCarTypeID = c.CarType.ITEMNAME ?? "未知", 
                  c.MaxVibrate,
                  c.AxleType,
                NewAxleType = c.AxleTypeInfo.ITEMNAME ?? "未知",
                VibrateCarCode = c.VibrateCarCode,
                VibrateCode = c.VibrateCode      
             }).OrderBy(c => c.HeadLicense, OrderByType.Desc).ToListAsync();
    
     //修复后
     var query = await db.QueryableWithAttr<IndividualResoureces>()
        .Includes(c => c.CarType)
        .Includes(c => c.AxleTypeInfo)
        .With(SqlWith.NoLock)
        .Where(c => 
        c.State == 0
        &&c.VibrateState==1 
        && c.VibrateCode != null 
        && c.VibrateCode.Length >= 12).Select(c =>new 
        {
            HeadLicense=c.HeadLicense,
            CarTypeID=c.CarTypeID,
            CarType=c.CarType,    //NewCarTypeID = c.CarType.ITEMNAME ?? "未知",
            MaxVibrate =c.MaxVibrate,
            AxleType=c.AxleType,
            AxleTypeInfo=c.AxleTypeInfo,    //NewAxleType = c.AxleTypeInfo.ITEMNAME ?? "未知",
            VibrateCarCode = c.VibrateCarCode,
            VibrateCode = c.VibrateCode
        }).OrderBy(c => c.HeadLicense, OrderByType.Desc).ToListAsync();
        
        var result = query.Select(c =>new{
            HeadLicense = c.HeadLicense,
            CarTypeID = c.CarTypeID,
            NewCarTypeID = c.CarType?.ITEMNAME ?? "未知",
            MaxVibrate = c.MaxVibrate,
            AxleType = c.AxleType,
            NewAxleType = c.AxleTypeInfo?.ITEMNAME ?? "未知",
            VibrateCarCode = c.VibrateCarCode,
            VibrateCode = c.VibrateCode
        });


    0 回复
  • 认真看文档,跨库导航很多功能不能用的。

    0 回复