My Table fileds and values:
IdFavorite : 1,2,3,4,5
FavoriteName : Fav1, Fav2, Fav3, Fav4, Fav5
UserId : 1, 3, 3, 4, 3
PublicFavorite : 0, 1, 0, 1, 0
As of now I used following Linq query to get the list of Favorite Names basd on the User ID
public IList<ReportFavorite> GetReportFavorites(int userId)
{
return _reportFavoriteRepository.GetMany(x => x.UserId == userId).ToList();
}
Now, the condition is as above plus , I need to get all the Favorite Names that has PublicFavorite is 1. I need the Linq query according to this condition. Thanks.
For eg: If My User Id is 3, then I should get the Favorite Names as Fav2 , Fav3 , Fav5 and also Fav4 (since PublicFavorite is 1)
var res =
from item in _reportFavoriteRepository
where item.UserId == userId || item.PublicFavorite == publicFavorite
select item.FavoriteName;
I used the following code as per Jon's comment. It is working fine as expected.
GetMany(x => x.UserId == userId || x.PublicFavorite == 1)
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.