如果您正在使用动态对象:
var email = (from c in dataContext.tblC
where c.AA == aa
select new {
email = x.email,
secemail = c.secEmail,
// ...
}).ToList(); // IList<dynamic> & IDE will know what properties
// you supplied in the `select new { }`
否则构建一个模型并填充它:
public class SelectModel
{
public String email { get; set; }
public String secemail { get; set; }
}
var email = (from c in dataContext.tblC
where c.AA == aa
select new SelectModel {
email = x.email,
secemail = c.secEmail,
// ...
}).ToList(); // IList<SelectModel>
如果您希望将返回的行转换为电子邮件to
标题:
var email = String.Join(", ", (
from c in dataContext.tblC
where c.AA == aa
select c.email
).AsEnumerable());
这将使:
+------------------+
| email |
|------------------|
| foo@contoso.com |
| bar@contoso.com |
| baz@contoso.com |
+------------------+
变成:
foo@contoso.com, bar@contoso.com, baz@contoso.com
多列连接:
var email = (from c in dataContext.tblC
where c.AA == AA
select new { email = c.email, secEmail = c.secEmail }).AsEnumerable();
var to = String.Join(", ",
email.Select(x => x.email)
.Concat(email.Select(y => y.secEmail))
// .Concat(eail.Select(y => x.thirdColumn))
// ...
);