如何在 F# 中使用 EF Include 方法(加载相关数据)?
How to use EF Include method(to load related data) in F#?
如何使用 Include 方法在 F# 中预先加载相关数据我试过这个:
_ctx.Reports.Include(x => x.Category)
并收到以下错误:
Severity Code Description Project File Line Suppression State
Error FS0041 A unique overload for method 'Include' could not be determined based on type information prior to this program point. A type annotation may be needed.
Known type of argument: ^_arg3
Candidates:
- (extension) Linq.IQueryable.Include<'TEntity when 'TEntity : not struct>(navigationPropertyPath: string) : Linq.IQueryable<'TEntity>
- (extension) Linq.IQueryable.Include<'TEntity,'TProperty when 'TEntity : not struct>(navigationPropertyPath: Linq.Expressions.Expression>) : Query.IIncludableQueryable<'TEntity,'TProperty> SharpNews.Application E:[=11=]DevelopingLearn\BackEnd\ASP.NET Core\SharpNews\SharpNews.Application\Admin\Report\GetReports.fs 44 Active
还有两个错误是 x 未定义
我使用的语法不正确吗?
转换为 seq
或 IEnumerable<_>
就可以了
context.Users
.Include(fun u -> u.Roles :> seq<Role>)
open System.Collections.Generic
context.Users
.Include(fun u -> u.Roles :> IEnumerable<Role>)
.ThenInclude(fun r -> r.Permissions)
如何使用 Include 方法在 F# 中预先加载相关数据我试过这个:
_ctx.Reports.Include(x => x.Category)
并收到以下错误:
Severity Code Description Project File Line Suppression State Error FS0041 A unique overload for method 'Include' could not be determined based on type information prior to this program point. A type annotation may be needed.
Known type of argument: ^_arg3
Candidates: - (extension) Linq.IQueryable.Include<'TEntity when 'TEntity : not struct>(navigationPropertyPath: string) : Linq.IQueryable<'TEntity> - (extension) Linq.IQueryable.Include<'TEntity,'TProperty when 'TEntity : not struct>(navigationPropertyPath: Linq.Expressions.Expression>) : Query.IIncludableQueryable<'TEntity,'TProperty> SharpNews.Application E:[=11=]DevelopingLearn\BackEnd\ASP.NET Core\SharpNews\SharpNews.Application\Admin\Report\GetReports.fs 44 Active
还有两个错误是 x 未定义
我使用的语法不正确吗?
转换为 seq
或 IEnumerable<_>
就可以了
context.Users
.Include(fun u -> u.Roles :> seq<Role>)
open System.Collections.Generic
context.Users
.Include(fun u -> u.Roles :> IEnumerable<Role>)
.ThenInclude(fun r -> r.Permissions)