none
Duplicated values RRS feed

  • Question

  • Hi guys, I'm developing a web application using entity framework.
    I need do a select and pass values for a Ilist but return duplicated values.

     IQueryable<establishmentInfo> filter = (from x in db.establishments
                                             join t in db.establishment_categories on x.id equals t.establishment
                                             join q in db.categories on t.category equals q.id
                                             where (x.name.ToUpper().Contains(search.ToUpper()))
                                             select new establishmentInfo
                                             {
                                                 id = x.id,
                                                 name = x.name,
                                                 id_category = q.id,
                                                 category = q.name,
                                             });
    IList<establishmentInfo>establishments = filter.ToList();
           

    Establishment Table

    id    name     email

    1     AAA         a@a.com

    2     BBB         b@b.com

    Establishment_categories

    id     establishment       category

    1              1                       1

    2              1                       2

    3              2                       1

    Categories

    id            name

    1             alpha

    2             beta

    The problem is that return 2 establishments, one with category 1 and other with cateogry 2.
    I need remove one of this.

    Anyone can help?

    Wednesday, October 14, 2020 12:51 PM

All replies