I have trying to run the following code:
[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();
}
}
however when it runs, I recieve an error message that states:
"Message:Test method Integration_Services_Tests.UnitTest1.TestMethod3 threw exception: System.Linq.Dynamic.ParseException: '.' or '(' expected Test cleanup method Integration_Services_Tests.UnitTest1.TestMethod3 threw exception. System.Linq.Dynamic.ParseException: System.Linq.Dynamic.ParseException:'.' or ')' expected."
Does anybody know what this means and how to overcome it?
According to this question , you might need to load all of the records into memory, then call context.SRS_Ticket_Transaction_Stage.DeleteOnSubmit()
for each item:
[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();
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.