开发者

Compare column against valid values

I have 2 datasets ds1 an开发者_如何学编程d ds2 ds1 contains valid values used in ds2 for e.g. ds1 contains subject table containing Maths, Science, History. ds2 contains Student table Student table contains Subject column. ds2->Student->Subject values should be present in ds->subject table.

How to implement this type of validation in effective way. I don't want to iterate through each row and column of student table.

e.g.

Students Table

Name Subject

Peter Maths

George Science

Joe IT

Roger History

Subjects Table

Subject

Maths

Science

Maths

History

Now I want to validate the data in Students Table against Subject table Check if the Subject is present in Subjects table or not. Here I want row Joe IT since IT is not present in Subjects table it is invalid.

Similarly , I need to check Students table data with multiple tables like Subjects.

I want LINQ query.


Use following query

var noSubject =
  ds.Student.AsEnumerable().Where(s => ds.Subject.Rows.Find(s.Subject) == null);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜