0

可能重复:
在 linq 查询中使用字典

如何IN使用 LINQ 发表声明?

是)我有的

    var t = from i in emails
            where i.Credencials_Id == agenciaid
            select new
            {
                i.Alias,
                i.Name,
                i.Description,
                i.Comentas,
                i.DateHour,
                i.Imovel_Id,
                i.Email,
                i.EmailCaptador
            };

我想要什么(像这样)

    var t = from i in emails
            where i.Credencials_Id IN (agenciaid)
            select new
            {
                i.Alias,
                i.Name,
                i.Description,
                i.Comentas,
                i.DateHour,
                i.Imovel_Id,
                i.Email,
                i.EmailCaptador
            };

int imovel = Convert.ToInt32(t.First().Imovel_Id);
4

1 回答 1

1

当您使用 LINQ to Objects 时,您可以使用:

from i in emails
where agenciaid.Contains(i.Credencials_Id)
select new
{
    i.Alias,
    i.Name,
    i.Description,
    i.Comentas,
    i.DateHour,
    i.Imovel_Id,
    i.Email,
    i.EmailCaptador
};
于 2012-12-05T15:38:07.870 回答