I have a Database with a Table named Fruits. In the table I have 3 columns: Name, Date, Remove.
Now i have inserted 3 rows, with a value like
Apple----20/10/12----N
Mango----21/12/12----Y
Banana--- 15/07/12----N
Grapes----18/12/12----Y
I want to delete the 2 rows which is marked as ‘Y.
This I want to achive using Linq in c# code. Initally I am establishing a connection to the DB using a connection string. I will get the device context DC, and with this I will copy all the rows.
Now I will enumerate the rows marked as N and I will call remove.
Once I do remov, I will do: dc.deleteonSubmit<tableName>(var).
After this, I should call dc.submittsavechages(); or what to make DB look like:
Mango----21/12/12----Y
Grapes----18/12/12----Y
If I query in sql query analyzer i should get above result. How to do this in LINQ?
Try this: