I'm finally getting around to working with DAL 2. So far so good. Simple CRUDS are easy enough to do, and the code is down drastically for those operations. Except now I need to join to another table. Here is my example
[TableName("Jobs")]
[PrimaryKey("JobId", AutoIncrement = true)]
[Cacheable("Jobs", CacheItemPriority.Default, 20)]
[Scope("ModuleId")]
class Job
{
public int JobId { get; set; }
public int ModuleId { get; set; }
public string JobTitle { get; set; }
public int CategoryId { get; set; } //JOIN ME
}
public IEnumerable<Job> GetJobs(int moduleId)
{
IEnumerable<Job> t;
using (IDataContext ctx = DataContext.Instance())
{
var rep = ctx.GetRepository<Job>();
t = rep.Get(moduleId);
}
return t;
}
That CategoryId joins to another table. In that table is CategoryName, which I want to pull in when doing selects. I could use some real examples on how the DAL 2 does joins. I feel this is really lacking in the documentation.
From what I can tell, I can add
[IgnoreColumn]
public string CategoryName{ get; set; }
But how do I populate the column it in my controller? I feel like I'm missing something obvious.