以下の QueryableEntities メソッド
では、期待しているため返すことができないものをIEnumerable<Competition>.AsQueryable()
返しますIQueryable<Competition>
IQueryable<T>
返すメソッドは 1 つしか記述できずIQueryable<Competition>
、IQueryable<Submission>
やり方わかる人いたら教えてください よろしくお願いします
public partial class WinBoutsDataContext<T> : System.Data.Linq.DataContext where T : class
{
public IQueryable<T> QueryableEntities
{
get
{
if (typeof(T).Equals(typeof(Model.Competition)))
{
return this.ConvertToCompetitionList(
this.GetTable<Storage.Competition>()).AsQueryable();
}
else if(typeof(T).Equals(typeof(Model.Submission)))
{
return this.ConvertToSubmissionList(
this.GetTable<Storage.CompetitionEntry>()).AsQueryable();
}
}
}
public DataAccess.Model.Competition ConvertToCompetition(DataAccess.Storage.Competition comp)
{
DataAccess.Model.Competition modelComp = new DataAccess.Model.Competition
{
CompetitionID = comp.CompetitionID,
Active = comp.Active,
CompetitionStatusID =
comp.CompetitionStatusID,
Duration = comp.Duration,
EndDate = comp.EndDate,
Entrants = comp.Entrants,
Featured = comp.Featured,
Image = comp.Image,
IsOvertime = comp.IsOvertime,
MaxEntrants = comp.MaxEntrants,
Notes = comp.Notes,
OvertimeDuration = comp.OvertimeDuration,
OvertimeEnd = comp.OvertimeEnd,
OvertimeStart = comp.OvertimeStart,
ParentCompetitionID = comp.ParentCompetitionID,
Prize = comp.Prize, StartDate = comp.StartDate,
SuggestedBy = comp.SuggestedBy,
Summary = comp.Summary,
Title = comp.Title
};
return modelComp;
}
public IEnumerable<DataAccess.Model.Competition> ConvertToCompetitionList(IEnumerable<DataAccess.Storage.Competition> compList)
{
List<DataAccess.Model.Competition> compModelList = new List<DataAccess.Model.Competition>();
foreach (DataAccess.Storage.Competition comp in compList)
{
compModelList.Add(ConvertToCompetition(comp));
}
return compModelList;
}
}