第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

表達式<Func<PartJoinTable, bool>> predicate=null;

表達式<Func<PartJoinTable, bool>> predicate=null;

C#
慕妹3242003 2021-11-28 19:47:42
 Expression<Func<PartJoinTable, bool>> predicate = null; var query2 = query.Join(partJoinTableRepository.GetPartJoinQuery(),                         "x.PartID", "PartID", "inner" + row + "", null); foreach (var item1 in query) {     list.Add(new PartJoinTable     {          ProductTypeId = item1.x.ProductTypeId,          PartId = item1.x.PartId     });  }  predicate = PredicateBuilder.True(list.AsQueryable());  if (typeid=="3")  {      if (row == 0)      {          predicate1 = predicate1.And(z => cpaclassids.Contains(z.x.ProductTypeId.ToString()));      }      else      {          predicate = predicate.And(x => cpaclassids.Contains(x.ProductTypeId.ToString()));       }    }    row++;}int lst1 = query.Where(predicate).Select(x => x).Distinct().ToList().Count();無法從“System.Linq.Expressions.Expression>”轉換為“System.Func<, bool>”我無法檢索結果,因為它在我聲明變量時顯示上述錯誤 Expression<Func<PartJoinTable, bool>> predicate = null;
查看完整描述

2 回答

?
長風秋雁

TA貢獻1757條經驗 獲得超7個贊

回答


表達式>謂詞=空;在 where 條件(query.Where(謂詞))中引發(fā)錯誤



if (predicate != null)

    query = query.Where(predicate);


int lst1 = query.Distinct().Count();

where僅當它存在時才添加子句。使用.ToList()之前.Count()你伸出的每一行從數(shù)據(jù)庫到內存中。


查看完整回答
反對 回復 2021-11-28
?
繁星淼淼

TA貢獻1775條經驗 獲得超11個贊

您可以使用?-編寫,它可以節(jié)省以下問題:if (predicate != null)

這是完整的代碼:

int lst1 = query.Where(predicate)?.Select(x => x)?.Distinct()?.ToList()?.Count;

你只能寫:Count- 類中的屬性List


查看完整回答
反對 回復 2021-11-28
  • 2 回答
  • 0 關注
  • 233 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號