I am trying to use T4 to generate code for the following:
public virtual IList<Frequency> GetAll()
{
using (var wc = new WCDataClassesDataContext())
{
return wc.Frequencies.ToList();
}
}
public virtual IList<Frequency> GetAll(Expression<Func<Frequency, bool>> whereClause)
{
using (var wc = new WCDataClassesDataContext())
{
return wc.Frequencies.Where(whereClause).ToList();
}
}
In T4 i am using:
foreach (var entity in typeMapper.GetItemsToGenerate<EntityType>(itemCollection))
{
fileManager.StartNewFile(entity.Name + "BaseFinder.cs");
BeginNamespace(code);
#>
<#=codeStringGenerator.UsingDirectives(inHeader: false)#>
using System.Linq;
using System.Linq.Expressions;
<#=codeStringGenerator.EntityClassOpening(entity)#>
{
public virtual IList<<#=entity.Name #>> GetAll()
{
using (var wc = new WCDataClassesDataContext())
{
return wc.[[Frequencies]].ToList();
}
}
public virtual IList<<#=entity.Name #>> GetAll(Expression<Func<<#=entity.Name #>, bool>> whereClause)
{
using (var wc = new WCDataClassesDataContext())
{
return wc.[[Frequencies]].Where(whereClause).ToList();
}
}
......
}
Instead of [[Frequencies]] i want the main table name that the entity is mapped to. I am trying to setup various getters which can be used easily in the classes.
Could you tell me what is the solution to do this, or there could be some other way to do this?
Hope you got my point.
Thanks.