I have the following query in sql,
select * from dbo.WaitingLists where WaitingListTypeId in (1) or StakeBuyInId in (Select StakeBuyInId from dbo.WaitingLists where StakeBuyInId in (5) and WaitingListTypeId = 2)
in this case, sometimes StakeBuyInId will be null or WaitingListTypeId will be null null. I want to execute this query through linq C # in the following code.
public GameListItem[] GetMyWaitingList(Guid UserId, int LocalWaitingListTypeId, int GlobalWaitingListTypeId, 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 (LocalWaitingListTypeId > 0 || (GlobalWaitingListTypeId > 0 && StakeBuyInIds != null)) { objWaitingListUser = objWaitingListUser.Where(x => x.WaitingListTypeId == LocalWaitingListTypeId || (x.WaitingListTypeId == GlobalWaitingListTypeId && StakeBuyInIds != null ? StakeBuyInIds.Contains((Int32)x.StakeBuyInId) : true) ); } return objtempGameListItem.ToArray(); }
Here, StakeBuyInIds int [] will sometimes be null, while I will perform the linq operation for the above sql query. Thanks for any help.
source share