TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
rajRana Thakur
NA
19
11.3k
How to Update Data table Using Linq
Sep 5 2014 12:50 PM
DataSet ds = new DataSet();
DataTable dt = new DataTable();
dt.Columns.Add("Id", typeof(int));
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("Address", typeof(string));
dt.Columns.Add("Salary", typeof(int));
dt.Columns.Add("Status", typeof(int));
dt.Columns.Add("DateOFName", typeof(DateTime));
DataRow dr = dt.NewRow();
dr["Id"] = 1;
dr["Name"] = "Umesh";
dr["Address"] = "Kolhapur";
dr["Salary"] = 32000;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["Id"] = 2;
dr["Name"] = "mahesh";
dr["Address"] = "Pune";
dr["Salary"] = 15000;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["Id"] = 3;
dr["Name"] = "Vinayak";
dr["Address"] = "Kolhapur";
dr["Salary"] = 18000;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["Id"] = 4;
dr["Name"] = "Sagar";
dr["Address"] = "Mumbai";
dr["Salary"] = 25000;
dt.Rows.Add(dr);
This code is working............
IEnumerable<DataRow> rows1 = dt.Select("Id>2 and name not like '%s%'");
rows1.ToList().ForEach(r => r.SetField("Name", "AnotherName"))
if i change into one line ,then it no work
IEnumerable<DataRow> rows1 = dt.Select("Id>2 and name not like '%s%'").
ToList().ForEach(r => r.SetField("Name", "AnotherName"))
Reply
Answers (
1
)
How can i extact this output using linq
how to modify the list which is obtained by linq