日期:2014-05-20 浏览次数:21005 次
var result = from ip in lqDB.IP_Table
where ID == '1' (查询某一条记录)
select new
(
IPA = ip.IP_LIST
);
string sql =string.Join("|",result.ToArray());
List<string> list = new List<string>();
list.Add("172.168.1.1|172.168.1.2|172.168.1.3|");
var result = from ip in list
select new { ip };
foreach (var item in result)
MessageBox.Show(item.ip);
------解决方案--------------------
var result = from ip in lqDB.IP_Table
where ID == '1' (查询某一条记录)
select ip.IP_LIST; //此处不要使用匿名类
string sql =string.Join("|",result.ToArray());
------解决方案--------------------
其实使用匿名类也是可以了,只是代码繁琐了点:
var result = from ip in lqDB.IP_Table
where ID == '1' (查询某一条记录)
select new
(
IPA = ip.IP_LIST
);
string sql =string.Join("|",result.Select(p=>p.IPA).ToArray());