lolo lolo - 1 year ago 104
C# Question

Do not find DeleteOnSubmit method

Im want to delete rows from a table that in my data base.
i have the member

private static WeightScaleEntities Weight = new Weight();

this member contains my database. in the data base i have table: User_Activity.

I want to delete rows from user activity by given i_UserActivityId, as follow:

//Get the rows for delete
var deleteUserActivities = from details in Weight.User_Activity
where details.Id == i_UserActivityId
select details;

Now i want to delete this rows, so i tried to do:

foreach (var item in deleteUserActivities)

and i dont get the method DeleteOnSubmit!

there is another option???

Answer Source

User_Activity.*: is that a typo?

What I think you want is:

foreach (var item in deleteUserActivities)

And then SaveChanges() on the object context.

BTW, a static object context is not a good idea. You should carefully control the life cycle of object contexts.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download