two conditions checking in where clause using linq 2 entites

后端 未结 3 1205
春和景丽
春和景丽 2021-02-05 15:59

hi i have table called products with columns

                 product_id
                 prodcut_name
                 prodcut_price( values like 1200,2000,3000         


        
3条回答
  •  死守一世寂寞
    2021-02-05 16:42

    from p in dbcontext.products
    join c in dbcontext.category on p.category_id equals c.category_id
    where p.product_price > 500 && p.product_price < 10000 && c.Name == "a"
    select p
    

    This will return you an IQueryable with the filtered results.

    Based on Vittore's answer below, if there is a foreign key constraints this would be the more appropriate version:

    from p in dbcontext.products
    where p.category.name =='a' && p.product_price > 500 && p.product_price < 10000
    select p;
    

提交回复
热议问题