ファンドのデータ値を含むこのテーブルがあり、各ファンドの最新の値(FundId)を選択したいと思います。このクエリを実行すると問題が発生します。「指定された方法はサポートされていません」。
var q = from f in ctx.FundDatas
group f by f.FundId into g
let latestDataItem = g.OrderByDescending(r => r.DateOfValue).FirstOrDefault()
select new {
g.Key, LatestDataItem = latestDataItem
};
var list = q.ToList(); //Executed and exception is thrown
なぜこの注文は仕事ではないのですか?KeyとDateOfValueだけを取得したくない場合は、「let」の部分をスキップして、次のように選択します。
select new {
g.Key,
LatestDateOfValue = g.Max(y=>y.DateOfValue)
};
上記は機能します...しかし、最大日だけでなく、各ファンドデータ項目の最新のオブジェクト全体が必要です。
内部例外スタックトレースは次のとおりです。
[NotSupportedException: Specified method is not supported.]
MySql.Data.Entity.SqlGenerator.Visit(DbApplyExpression expression) +28
System.Data.Common.CommandTrees.DbApplyExpression.Accept(DbExpressionVisitor`1 visitor) +25
MySql.Data.Entity.SqlGenerator.VisitInputExpression(DbExpression e, String name, TypeUsage type) +35
MySql.Data.Entity.SelectGenerator.VisitInputExpressionEnsureSelect(DbExpression e, String name, TypeUsage type) +21
MySql.Data.Entity.SelectGenerator.Visit(DbProjectExpression expression) +38
System.Data.Common.CommandTrees.DbProjectExpression.Accept(DbExpressionVisitor`1 visitor) +25
MySql.Data.Entity.SelectGenerator.GenerateSQL(DbCommandTree tree) +60
MySql.Data.MySqlClient.MySqlProviderServices.CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree) +376
System.Data.Common.DbProviderServices.CreateCommandDefinition(DbCommandTree commandTree) +125
System.Data.EntityClient.EntityCommandDefinition..ctor(DbProviderFactory storeProviderFactory, DbCommandTree commandTree) +442
.NETコネクタ6.5.4.0でMySQLを実行しています。
編集:テーブル定義:
FundId int(6), PK
DateOfValue date, PK
Value double(12,6)