I have int [] and want to check if a particular property from the list exists in the array or not. Here is my property class,
public class WaitingLists { [Key] public Int32 Id { get; set; } public Guid UserId { get; set; } public Int32 GameTableId { get; set; } public Int32 WaitingListTypeId { get; set; } **public Int32 ? StakeBuyInId { get; set; }** }
Then I want to check that StakeBuyInId exists in my list.
Here is the code for Linq,
public GameListItem[] GetMyWaitingList(Guid UserId, int[] WaitingListTypeIds, int[] StakeBuyInIds) { ProviderDB db = new ProviderDB(); List<GameListItem> objtempGameListItem = new List<GameListItem>(); List<GameTables> objGameTablesList = new List<GameTables>(); var objWaitingListUser = db.WaitingLists.Where(x => x.UserId.Equals(UserId)); if (WaitingListTypeIds != null) { objWaitingListUser = objWaitingListUser.Where(x => WaitingListTypeIds.Contains(x.WaitingListTypeId)); } **if (StakeBuyInIds != null) { objWaitingListUser = objWaitingListUser.Where(x => x.StakeBuyInId != null ? StakeBuyInIds.Contains(x.StakeBuyInId) : false); }** return objtempGameListItem.ToArray(); }
But it shows me an error that contains does not allow "int?". It overloads only "int". So you know how to use Contains for a null property using linq? Thanks for any help.
source share