我有實體下無法在自定義實體執行聯盟
public class A
{
public string TestMethodName { get; set; }
public string FailedFor { get; set; }
}
public class B
{
public string TestMethodName { get; set; }
public string FailedFor { get; set; }
}
我使用的是Windows窗體。如果我嘗試下
private void button2_Click(object sender, EventArgs e)
{
List<A> aCollection = new List<A>();
List<B> bCollection = new List<B>();
aCollection.Add(new A { TestMethodName = "Method1", FailedFor = "DPLServerURL" });
aCollection.Add(new A { TestMethodName = "Method2", FailedFor = "DPLServerURL" });
aCollection.Add(new A { TestMethodName = "Method3", FailedFor = "DPLServerURL" });
aCollection.Add(new A { TestMethodName = "Method4", FailedFor = "DPLServerURL" });
bCollection.Add(new B { TestMethodName = "Method1", FailedFor = "OrderXmlLocation" });
bCollection.Add(new B { TestMethodName = "Method2", FailedFor = "OrderXmlLocation" });
bCollection.Add(new B { TestMethodName = "Method5", FailedFor = "OrderXmlLocation" });
var xx = bCollection.Union(aCollection).ToList();
}
進行聯盟,因爲我得到錯誤的udner
Error 1 Instance argument: cannot convert from 'System.Collections.Generic.List<WindowsFormsApplication1.B>' to 'System.Linq.IQueryable<WindowsFormsApplication1.A>'
我怎樣才能做到這些實體的聯合/合併?
感謝
'xx'的預期類型是什麼? – 2013-03-01 11:19:47
xx應該是aCollection和bCollection的聯合。 – 2013-03-01 11:21:27
aCollection和bCollection是不同的類型 – Sergio 2013-03-01 11:22:37