I'm working with Breeze and love it but came across a stickler or two and am hoping to get a little help with one of them.
I'm using EF and SQL on the back-end of a database first model and have a one to many relationship with a Parent and Child table. When retrieving data, no matter what I try, it doesn't filter the data correctly when using the child id. Here's the code:
Client Code:
var query = breeze.EntityQuery.from("Parent")
var predicateChild = new breeze.Predicate('CHILD', 'any', 'CHILD_ID', '==', childId);
query = query.where(predicateChild );
var promise = collectionsManager
.executeQuery(query)
.then(querySuccess)
.catch(queryFailed);
Server Code:
[HttpGet]
[BreezeQueryable(MaxExpansionDepth = 5)]
public IQueryable<PARENT> Parent()
{
return _contextProvider.Context.PARENT;
}
The query does work, it finds the proper parent (so it seems the childId is being used) but returns all children, not just the one given in the predicate.
I've tried every way I can to get the results I want but I'm sure I'm missing something either in the server code or the EF layer.
In an effort to get this to work, I changed the server code to use the child table instead of the parent. If navigation is set in EF from child to parent, this works, but that presents a circular reference when stringifying the data later downstream (and I need to do this).
Any help is greatly appreciated.