public static ProjectModel GetProject(int ProjectId) { ProjectModel retVal = null; using (SparesDataContext dc = getDataContext()) { retVal = (from p in dc.tblProjects where p.ProjectId == ProjectId select new ProjectModel { ProjectId = p.ProjectId, UserId = p.UserId, PrimaryWhseId = p.PrimaryWhseId, SecondaryWhseId = p.SecondaryWhseId.Value, ProjectType = getProjectTypeEnum(p.ProjectType.Value), CustomerCode = p.CustomerCode, CustomerName = p.CustomerName, ProjectName = p.ProjectName, ProjectNum = p.ProjectNum, Date = p.Date, Comments = p.Comments } ).FirstOrDefault(); } return retVal; }and here's the ProjectModel:
public class ProjectModel : _BaseModel { public int ProjectId { get; set; } public int UserId { get; set; } public WarehouseModel PrimaryWarehouse { get; set; } public WarehouseModel SecondaryWarehouse { get; set; } public ProjectType ProjectType { get; set; } public string CustomerCode { get; set; } public string CustomerName { get; set; } public string ProjectName { get; set; } public string ProjectNum { get; set; } public DateTime Date { get; set; } public string Comments { get; set; } }Is it possible in this Linq query to pull the data from the Wharehouse table and populate the PrimaryWarehouse and SecondaryWarehouse properties with instances of those models inside this query?