I'm working with MVC3 C#.NET. I have a query that (up to now worked) which returns rows based off of the companyID:
var records = db.groupsToClassesMapping.Where(r => r.CompanyID == CompanyId);
The model looks like this:
[Table("Rpt_GroupsToClasses")]
public class GroupToClass
{
public int id { get; set; }
public string GroupName { get; set; }
public string ClassName { get; set; }
public int ClassIndex { get; set; }
public int CompanyID { get; set; }
}
and the DBContext looks like this:
public DbSet<GroupToClass> GroupsToClassesMapping { get; set; }
It used to be all of the table entries were filled, and the query would return results:
ID | Group Name | ClassName | ClassIndex | CompanyID
-----------------------------------------------------
1 | Pine | Merch | 1 | 1
2 | Oak | Non-merch | 4 | 1
However, I find myself needing to have some of the entries blank:
ID | Group Name | ClassName | ClassIndex | CompanyID
-----------------------------------------------------
1 | Pine | Merch | 1 | 1
2 | Oak | NULL | NULL | 1
and my query (where(r => r.companyID == CompanyId)) doesn't return anything. Is there something I need to do to the model fields to make this work right?