我有这个linq到实体行:
myentity.CityType.Add(context.Set<SiteCityType>().FindAsync(2));
实体 myentity 且 SiteCityType 是已定义的实体。 CityType 是 myentity 实体中定义的导航属性:
public virtual ICollection<SiteCityType> CityType { get; set; }
上面的linq行正常工作但我需要 FindAsync 方法获取List:
myentity.CityType.Add(context.Set<SiteCityType>().FindAsync('some list of ints'));
知道如何实施它?
答案 0 :(得分:2)
尝试创建扩展方法:
public class ExceptionInFinalizerObject
{
~ExceptionInFinalizerObject()
{
//Tried here both "Assert.Fail" and throwing an exception to be sure
Assert.Fail();
throw new Exception();
}
}
[TestFixture]
public class FinalizerTestFixture
{
[Test]
public void FinalizerTest()
{
CreateFinalizerObject();
GC.Collect();
GC.WaitForPendingFinalizers();
}
public void CreateFinalizerObject()
{
//Create the object in another function to put it out of scope and make it available for garbage collection
new ExceptionInFinalizerObject();
}
}
我建议“All()”方法不返回内存中的对象,例如,IQueryable。 因此,实际实施取决于您的架构。