如果有人可以在以下建議我會很感激: 我需要根據不同的條件(在我的情況適配器)來選擇不同的價值觀,我想是這樣的:條件選擇在Lambda表達式LINQ
return this.WrappedEntity.human_screen.SelectMany(e => e).Select(e =>
{
AHuman human = _unitOfWork.HumansRepo.GetById(e.human_uid.ToString());
if (e.vid_screen == "1" && human.Gender== Gender.Female)
{
return new SqlFemaleScreening(e);
}
else if (e.vid_screen == "1" && human.Gender== Gender.Male)
{
return new SqlMaleScreening(e);
}
else
{
return new SqlChildScreening(e);
}
});
但我得到以下錯誤:
ERROR: Type arguments for method "
System.Linq.Enumerable.SelectMany <TSource,TResult> (System.Collections.Generic.IEnumerable <TSource>, System.Func <TSource, int, System.Collections.Generic.IEnumerable <TResult>>)
"should be defined for use. Try to clearly define the type arguments.
非常感謝您提前!
我認爲當你說「它不正確」時,你的意思是說有某種編譯器錯誤?它說什麼? – Chris
它如何「不正確」?什麼是錯誤? – Lee
它有什麼問題?它是否會拋出異常,或者您擔心代碼質量? –