Hi,
I have the following linq query :
IQueryable<Message> messagesQuery = (from message in _context.Db.Messages
where message.MessageListId == item.MessageListId
&&
!_context.Db.ScheduleXMessages.Any(x => x.MessageId == message.MessageId && x.ScheduleId == item.ScheduleId)
select message);
if (randomSendMessage)
return (from mq in messagesQuery orderby Guid.NewGuid() select mq).FirstOrDefault();
return (from mq in messagesQuery orderby mq.OrderIndex select mq).FirstOrDefault();
Now, if randomSendMessage is true, the order by doesn't get added to the select. if it's false, then the Order By OrderIndex is added to the select.
Any ideas on what might be going on ?
Thanks.
Edit Nope, it doesn't work if I select the column upfront. It just sends the guid as a parameter and instead of doing an orderby newid() , it does it by using one single guid