I have the following method:
public DataTable.DataTablesPage<DataTable.UserModel> DataTableUserListByAttendees(int geoArea, int CurrentUserID)
{
var result = from i in _dbContext.Users
where i.GeographicalAreas.Any(p => p.GeoAreaID == geoArea)
select new DataTable.UserModel()
{
ID = i.ID,
Company = i.Company,
DCMember = (i.UserId != null),
FirstName = i.FirstName,
LastName = i.LastName
};
}
it works fine, but it returns entities that dont have the geoArea proeprty set.
public DataTable.DataTablesPage<DataTable.UserModel> DataTableUserListByAttendees(int? geoArea, int CurrentUserID)
{
var result = from i in _dbContext.Users
where i.GeographicalAreas.Any(p => p.GeoAreaID == geoArea)
select new DataTable.UserModel()
{
ID = i.ID,
Company = i.Company,
DCMember = (i.UserId != null),
FirstName = i.FirstName,
LastName = i.LastName
};
}
How can I change the query so that it returns only entities that have their geoArea property set (aka is not null).
or conditionally add the where to the query