本文介绍了从asp.net中的数据表中选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
好的..还有一个问题是,
我有onedatatable列是ruleid,descp
和在seconddatatable,我有列hotelid,ruleid
现在我想检查
如果secondtable.contains hotelid,选择ruleid,如果(onedatatable.contains ruleid from seconddatatable,选择descp in onedatatable)
i希望你明白..
ok..one other question is ,
I have onedatatable where column is ruleid,descp
and in seconddatatable, i have column hotelid,ruleid
now i want to check
if secondtable.contains hotelid,select ruleid and,if(onedatatable.contains ruleid from seconddatatable,select descp in onedatatable)
i hope u understood..
推荐答案
DataTable dtOne = new DataTable();
dtOne.Columns.Add("ruleid", typeof(int));
dtOne.Columns.Add("descp", typeof(string));
dtOne.Rows.Add(1, "hello");
dtOne.Rows.Add(2, "there");
dtOne.Rows.Add(3, "world");
DataTable dtTwo = new DataTable();
dtTwo.Columns.Add("hotelid", typeof(int));
dtTwo.Columns.Add("ruleid", typeof(int));
dtTwo.Rows.Add(1, 1);
dtTwo.Rows.Add(2, 1);
dtTwo.Rows.Add(3, 2);
dtTwo.Rows.Add(4, 3);
dtTwo.Rows.Add(5, 4);
var results = from rowOne in dtOne.AsEnumerable()
join rowTwo in dtTwo.AsEnumerable() on rowOne.Field<int>("ruleId") equals rowTwo.Field<int>("ruleid")
where rowTwo.Field<int>("hotelid") == 3
select new { hotelid = rowTwo["hotelid"], descp = rowOne["descp"] };
这篇关于从asp.net中的数据表中选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!