任意のナビゲーション プロパティで Expand を使用しようとすると、次の例外が発生します。
$id: "1",
$type: "System.Web.Http.HttpError, System.Web.Http",
Message: "An error has occurred.",
ExceptionMessage: "'object' does not contain a definition for 'Include'",
ExceptionType: "Microsoft.CSharp.RuntimeBinder.RuntimeBinderException",
StackTrace: " at System.Web.Http.ApiController.<InvokeActionWithExceptionFilters>d__b.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
インクルードを Breeze コントローラー内に配置すると、すべて正常に動作します。クライアントで展開を使用せずに使用すると、そのエラーが発生します。どんな助けでも大歓迎です!
これは、データの取得を試みるために使用される URL です。
/breeze/maxsys/CallOutcomes?$expand=CallOutcomeAction
モデルはこちら
[Table("CallOutcomes")]
public class CallOutcome {
[Key]
public int Id { get; set; }
[Required]
public string Description { get; set; }
public bool IsInternal { get; set; }
public int CallOutcomeActionId { get; set; }
[ForeignKey("CallOutcomeActionId")]
[InverseProperty("CallOutcomes")]
public CallOutcomeAction CallOutcomeAction { get; set; }
public ICollection<CallOutcomeHistory> CallOutcomeHistories { get; set; }
}
コントローラーは次のようになります (他の get メソッドの一部を削除しました)。
[BreezeController]
[Authorize]
[RequireHttps]
public class MaxsysController : ApiController
protected IMaxsysBreezeRepository Repository { get; set; }
public MaxsysController(IMaxsysBreezeRepository repository)
{
Repository = repository;
}
[HttpGet]
public IQueryable<CallOutcome> CallOutcomes()
{
return Repository.CallOutcomes;
}
}
エラーは、BreezeQueryableAttribute.cs のこのメソッドから発生しています。
public virtual IQueryable ApplyExpand(IQueryable queryable, string expandsQueryString, HttpRequestMessage request)
{
(from s in expandsQueryString.Split(new char[] { ',' }) select s.Trim()).ToList<string>().ForEach(delegate (string expand) {
queryable = (IQueryable) ((dynamic) queryable).Include(expand.Replace('/', '.'));
});
return queryable;
}
パラメータ値は次のとおりです。
queryable = {SELECT
[Extent1].[Id] AS [Id],
N'b1d28373-98a2-4a88-9733-7872acd28bd2' AS [C1],
[Extent1].[Description] AS [Description],
[Extent1].[IsInternal] AS [IsInternal],
[Extent1].[CallOutcomeActionId] AS [CallOutcomeActionId],
N'CallOutcomeAction' AS [C2],
N'b1d28373-98a2-4a88-9733-7872acd28bd2' AS [C3],
[Extent2].[Id] AS [Id1],
[Extent2].[Description] AS [Description1]
FROM [dbo].[CallOutcomes] AS [Extent1]
INNER JOIN [dbo].[CallOutcomeActions] AS [Extent2] ON [Extent1].[CallOutcomeActionId] = [Extent2].[Id]}
expandsQueryString = "CallOutcomeAction"
HttpRequestMessage ={Method: GET, RequestUri: 'http://127.0.0.1:82/breeze/maxsys/CallOutcomes?$expand=CallOutcomeAction', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Connection: keep-alive
Accept: text/html
Accept: application/xhtml+xml
Accept: application/xml; q=0.9
Accept: */*; q=0.8
Accept-Encoding: gzip
Accept-Encoding: deflate
Accept-Encoding: sdch
Accept-Language: en-US
Accept-Language: en; q=0.8
Host: 127.0.0.1:81
User-Agent: Mozilla/5.0
User-Agent: (Windows NT 6.1; WOW64)
User-Agent: AppleWebKit/537.36
User-Agent: (KHTML, like Gecko)
User-Agent: Chrome/27.0.1453.94
User-Agent: Safari/537.36
}}