エラーが発生しています:
Unable to locate member:
展開されたエンティティ プロパティでフィルタリングする場合。
これは機能します:
http://localhost:60760/XXX/XXX/productcollection?$filter=Code%20eq%20'da'&$expand=PRODUCT_LINE
そして戻り値:
[{"$id":"1","$type":"DoorDesigner.Models.COLLECTION, DoorDesigner","ID":81,"Descr":"Some Description","Code":"Da","DISPLAY_HTML":"","DEFAULT_IMAGE_PATH":"../Content/Images/TempCollections/0000_Layer 54.jpg","PRODUCT_LINE":[{"$id":"2","$type":"DoorDesigner.Models.PRODUCT_LINE, DoorDesigner","ID":213,"CollectionID":81,"Code":"AT","Descr":"ATHENA","LongDescr":"ATHENA","DEFAULT_IMAGE_PATH":"../Content/Images/TempCollections/0000_Layer%2054.jpg","Product_Code_Group":"AT","COLLECTION":{"$ref":"1"},"PRICING_DOOR":[],"POSSIBLE_INSULATION":[],"POSSIBLE_WINDOW":[],"WINDOWs":[]},{"$id":"3","$type":"DoorDesigner.Models.PRODUCT_LINE, DoorDesigner","ID":217,"CollectionID":81,"Code":"CY","Descr":"CYPRUS","LongDescr":"CYPRUS","DEFAULT_IMAGE_PATH":"../Content/Images/TempCollections/Panel.jpg","Product_Code_Group":"CY","COLLECTION":{"$ref":"1"},"PRICING_DOOR":[],"POSSIBLE_INSULATION":[],"POSSIBLE_WINDOW":[],"WINDOWs":[]},{"$id":"4","$type":"DoorDesigner.Models.PRODUCT_LINE, DoorDesigner","ID":220,"CollectionID":81,"Code":"PI","Descr":"PINNACLE","LongDescr":"PINNACLE","DEFAULT_IMAGE_PATH":"../Content/Images/TempCollections/Windows.jpg","Product_Code_Group":"PI","COLLECTION":{"$ref":"1"},"PRICING_DOOR":[],"POSSIBLE_INSULATION":[],"POSSIBLE_WINDOW":[],"WINDOWs":[]},{"$id":"5","$type":"DoorDesigner.Models.PRODUCT_LINE, DoorDesigner","ID":227,"CollectionID":81,"Code":"WI","Descr":"WINDRIVER","LongDescr":"WINDRIVER","DEFAULT_IMAGE_PATH":"../Content/Images/TempCollections/Panel.jpg","Product_Code_Group":"WI","COLLECTION":{"$ref":"1"},"PRICING_DOOR":[],"POSSIBLE_INSULATION":[],"POSSIBLE_WINDOW":[],"WINDOWs":[]}]}]
これPRODUCT_LINE
は Expanded で、Descr
プロパティがあります。
ここで、フィルタする URL を変更するとPRODUCT_LINE.Descr
、次のエラーが表示されます。
http://localhost:60760/XXX/XXX/productcollection?$filter=PRODUCT_LINE/Descr%20eq%20'Athena'&$expand=PRODUCT_LINE
戻る:
{"$id":"1","$type":"System.Web.Http.HttpError, System.Web.Http","Message":"An error has occurred.","ExceptionMessage":"Unable to locate member: Descr","ExceptionType":"System.Exception","StackTrace":" at Breeze.WebApi.ParseTreeVisitor.VisitMemberExpr(ParseTreeNode node, Expression targetExpr, String memberName)\r\n at Breeze.WebApi.ParseTreeVisitor.<>c__DisplayClass3.<VisitNode>b__0(ParseTreeNode n)\r\n at System.Collections.Generic.List`1.ForEach(Action`1 action)\r\n at Breeze.WebApi.ParseTreeVisitor.VisitNode(ParseTreeNode node)\r\n at Breeze.WebApi.ParseTreeVisitor.VisitNode(ParseTreeNode node)\r\n at Breeze.WebApi.ParseTreeVisitor.Parse(Type rootType, ParseTreeNode node)\r\n at Breeze.WebApi.ExpressionTreeBuilder.Parse(Type rootType, String source)\r\n at Breeze.WebApi.ODataActionFilter.BuildFilterFunc(String filterQueryString, Type elementType)\r\n at Breeze.WebApi.ODataActionFilter.OnActionExecuted(HttpActionExecutedContext actionExecutedContext)\r\n at System.Web.Http.Filters.ActionFilterAttribute.CallOnActionExecuted(HttpActionContext actionContext, HttpResponseMessage response, Exception exception)\r\n at System.Web.Http.Filters.ActionFilterAttribute.<>c__DisplayClass2.<System.Web.Http.Filters.IActionFilter.ExecuteActionFilterAsync>b__0(HttpResponseMessage response)\r\n at System.Threading.Tasks.TaskHelpersExtensions.<>c__DisplayClass41`2.<Then>b__40(Task`1 t)\r\n at System.Threading.Tasks.TaskHelpersExtensions.ThenImpl[TTask,TOuterResult](TTask task, Func`2 continuation, CancellationToken cancellationToken, Boolean runSynchronously)"}
私が知る限り、これはエラーを生成している Breeze コードです。
protected virtual Expression VisitMemberExpr(ParseTreeNode node, Expression targetExpr, String memberName) {
var targetType = targetExpr.Type;
var member = targetType.GetMember(memberName).FirstOrDefault();
if (member == null) {
throw new Exception("Unable to locate member: " + memberName);
}
return Expression.MakeMemberAccess(targetExpr, member);
}
これは、展開されたプロパティでフィルター処理しようとしているすべての場所で、API 全体で発生しています。これらのフィルタリングに成功した人はいますか?
更新: エンティティ クエリは次のとおりです。
breeze.EntityQuery.from('ProductCollection')
.where('PRODUCT_LINE.Descr', '==', 'Athena')
.expand('PRODUCT_LINE');
AND APIController
[HttpGet]
public IQueryable<COLLECTION> productCollection() {
return _contextProvider.Context.COLLECTIONs;
}
コンテキスト定義:
public DbSet<COLLECTION> COLLECTIONs { get; set; }
そして最後にクラス定義
public partial class COLLECTION
{
public COLLECTION()
{
this.PRODUCT_LINE = new HashSet<PRODUCT_LINE>();
}
public int ID { get; set; }
public string Descr { get; set; }
public string Code { get; set; }
public string DISPLAY_HTML { get; set; }
public Nullable<System.DateTime> CREATED { get; set; }
public string CREATOR { get; set; }
public Nullable<System.DateTime> LAST_MODIFIED { get; set; }
public string LAST_USER { get; set; }
public string DEFAULT_IMAGE_PATH { get; set; }
public Nullable<bool> IS_DELETED { get; set; }
public virtual ICollection<PRODUCT_LINE> PRODUCT_LINE { get; set; }
}
public partial class PRODUCT_LINE
{
public PRODUCT_LINE()
{
this.PRICING_DOOR = new HashSet<PRICING_DOOR>();
this.POSSIBLE_INSULATION = new HashSet<POSSIBLE_INSULATION>();
this.POSSIBLE_WINDOW = new HashSet<POSSIBLE_WINDOW>();
this.WINDOWs = new HashSet<WINDOW>();
}
public int ID { get; set; }
public Nullable<int> CollectionID { get; set; }
public string Code { get; set; }
public string Descr { get; set; }
public string LongDescr { get; set; }
public string DISPLAY_HTML { get; set; }
public Nullable<System.DateTime> CREATED { get; set; }
public string CREATOR { get; set; }
public Nullable<System.DateTime> LAST_MODIFIED { get; set; }
public string LAST_USER { get; set; }
public string DEFAULT_IMAGE_PATH { get; set; }
public Nullable<bool> IS_DELETED { get; set; }
public string Product_Code_Group { get; set; }
public Nullable<int> DefaultInsulationId { get; set; }
public Nullable<int> DefaultWindowId { get; set; }
public virtual COLLECTION COLLECTION { get; set; }
public virtual ICollection<PRICING_DOOR> PRICING_DOOR { get; set; }
public virtual ICollection<POSSIBLE_INSULATION> POSSIBLE_INSULATION { get; set; }
public virtual ICollection<POSSIBLE_WINDOW> POSSIBLE_WINDOW { get; set; }
public virtual ICollection<WINDOW> WINDOWs { get; set; }
}
ありがとう、