我有以下列出如何選擇一個屬性不在整數列表中的列表?
List<int> toExclude = new List<int>(); //Assume I have number between 1-10
List<ReportObjectRelation> relations = new List<ReportObjectRelation>(); //Assume I have multiple `ReportObjectRelation` objects in this list
我需要拉的relations
的列表,其中CurrentObjectId = 6
和RemoteObjectId
不在toExclude
列表。
這是我ReportObjectRelation
對象
public class ReportObjectRelation
{
//Relation
public int Id { get; set; }
public string DisplayName { get; set; }
public string Alias { get; set; }
//Local Object
public int CurrentObjectId { get; set; }
public string CurrentObjectName { get; set; }
public int ForeignPropertyId { get; set; }
public string ForeignProperty { get; set; }
//Remote Object
public int RemoteObjectId { get; set; }
public string RemoteObjectName { get; set; }
public int LocalPropertyId { get; set; }
public string RemoteProperty { get; set; }
}
這裏是我試過
var f = allRelations.Where(x => x.CurrentObjectId == 6 && !toExceule.Exists(x.RemoteObjectId)).ToList();
但是這是給我下面的錯誤
不能使用REF OUT參數toExceule
一個匿名方法, lambda表達式或查詢表達式。
如何才能正確拉取CurrentObjectId == 6
和RemoteObjectId
不在toExceule
之間的關係列表?
兩個人都沒有工作。我仍然得到相同的錯誤 – Jaylen
@Jaylen檢查編輯。您需要分配out參數的副本。我不知道你爲什麼在你的情況下使用輸出參數。 – user3185569
創造了慾望的副本工作!謝謝 – Jaylen