我试图运行以下代码:
[TestMethod]
[TestCleanup]
public void TestMethod3()
{
using (var context = new CorporateDWTestEntities1())
{
//Deleting every row within the OLE_DB_Destination1 table.
var query = from c in context.SRS_Ticket_Transaction_Stage select c;
query.Delete();
context.SaveChanges();
}
}
然而,当它运行时,我收到一条错误消息,指出:
“消息:测试方法Integration_Services_Tests.UnitTest1.TestMethod3 抛出异常:System.Linq.Dynamic.ParseException:'。'要么 '(' 预期的测试清理方法 Integration_Services_Tests.UnitTest1.TestMethod3引发了异常。 System.Linq.Dynamic.ParseException: System.Linq.Dynamic.ParseException: ''或')'预期。“
有人知道这意味着什么,以及如何克服它?
答案 0 :(得分:0)
According to this question,您可能需要将所有记录加载到内存中,然后为每个项目调用context.SRS_Ticket_Transaction_Stage.DeleteOnSubmit()
:
[TestMethod]
[TestCleanup]
public void TestMethod3()
{
using (var context = new CorporateDWTestEntities1())
{
//Deleting every row within the OLE_DB_Destination1 table.
var query = from c in context.SRS_Ticket_Transaction_Stage select c;
var records = query.ToList();
foreach(var record in records)
{
context.SRS_Ticket_Transaction_Stage.DeleteOnSubmit(record);
}
context.SubmitChanges();
}
}