を渡すことはできませんI以下の機能があります。LINQの2 SQLは:のIQueryable <>パラメータ
public class InfrStadium
{
private InfrStadium(int iTeamId)
{
_teamId = iTeamId;
_sectors = InfrStadiumSector.GetTeamSectors(iTeamId);
...
}
public void Init()
{
use(_sectors);
}
IList<InfrStadiumSector> _sectors;
いくつかの方法は、それを呼び出す:
public class InfrStadium
{
private InfrStadium(int iTeamId, IList<InfrStadiumSector> sectors)
{
_teamId = iTeamId;
_sectors = sectors;
...
}
public static IList<InfrStadium> GetBestStadium(IQueryable<InfrStadiumSector> sectors)
{
IQueryable<InfrStadium> stadiums = from sector in sectors
group sector by sector.TeamId
into team_sectors
select new InfrStadium(team_sectors.Key)
;
return stadiums.ToList();
}
...
}
すべてがここに罰金です。しかし、問題がある、各チームのための 'InfrStadium'コンストラクタの中に、私は既に特定のチームのためにグループ化されたセクター情報を取得する必要があります。だから私は、そのような変更をした:
編集:IList<>
とのアプローチは
public static IList<InfrStadium> GetBestStadium(IQueryable<InfrStadiumSector> sectors)
{
IQueryable<InfrStadium> stadiums = from sector in sectors
group sector by sector.TeamId into team_sectors
select new InfrStadium(
team_sectors.Key,
team_sectors.ToList()
)
;
return stadiums.ToList();
}
を追加し、次のエラーを受信しました:
Queryable method call expected. Got 'team_sectors.ToList()'. Parameter name: info
なぜ?ここで何が間違っていますか?
別のアプローチ(それがすべてで動作する必要がある場合は、実際に、わからない):
private InfrStadium(int iTeamId, IQueryable<InfrStadiumSector> sectors)
{
_teamId = iTeamId;
_qSectors= sectors;
...
}
public void Init()
{
use(_qSectors.ToList());
}
IQueryable<InfrStadiumSector> _qSectors;
public static IList<InfrStadium> GetBestStadium(IQueryable<InfrStadiumSector> sectors)
{
IQueryable<InfrStadium> stadiums = from sector in sectors
group sector by sector.TeamId into team_sectors
select new InfrStadium(
team_sectors.Key,
team_sectors.AsQueryable()
)
;
return stadiums.ToList();
}
私の意図は、再びDBを要求しないオブジェクトコンストラクタに必要なデータの中に通過させることです。
しかし、私の場合は私がエラーを受信します。
Expression of type 'System.Int32' cannot be used for parameter of type 'System.Collections.Generic.IEnumerable`1[InfrStadiumSector]' of method 'System.Linq.IQueryable`1[InfrStadiumSector] AsQueryable[InfrStadiumSector](System.Collections.Generic.IEnumerable`1[InfrStadiumSector])'
私は全くエラーを理解していません。私のソースコードでは、「式の型」System.Int32 "はどこにありますか?私の場合は
私は...タイプIGrouping<int,InfrStadiumSector>
ため
「をAsQueryable()」メソッドを呼び出しています教えてください、任意の考えを歓迎します!