简体   繁体   中英

Entity framework linq query

I have this piece of code. What i need to do is to exclude mc_host_class values that are inside the list.

enter  var myList = (from p in db.Full
                      where ( (p.date_reception > begin & p.date_reception < end & !p.mc_host_class.Contains("NULL")) &

                     ( !p.mc_host_class.Contains( (
                            from p2 in db.exclure
                            where (p2.type.Contains("Host"))
                            group p2 by p2.libelle into g
                            select new { libellex = g.Key}).ToList()
                      )))
                      group p by p.mc_host_class into g
                      orderby g.Count() descending
                      select new
                      {
                          hostclassx = g.Key,
                          countx = g.Count()
                      }).ToList().Take(10);

Thank you for helping

If I understood your question, I think this could help you:

(!(
    from p2 in db.exclure
    where (p2.type.Contains("Host")
    group p2 by p2.libelle into g
    select new { libellex = g.Key}
).ToList().Contains(p.mc_host_class))

List1.Contains(value1) return a bool if a value1 is in List1, but you used it like value1.Contains(List1).

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM