breeze.js 当结束点 returns 多个结果集时不遵守 "noTracking" 选项
breeze.js not honoring the "noTracking" option when end point returns multiple result sets
考虑这个简单的查询:
return EntityQuery.from('myAPI')
.noTracking(true)
.using(manager).execute()
.then(querySucceeded)
.fail(queryFailed);
我的API是这样定义的:
[HttpGet]
public object myAPI()
{
// var userId = get the users id from auth ticket
var userPref = _contextProvider.Context.UserPreferences.Where(u => u.userId == userId);
var userOptions = _contextProvider.Context.UserOptions.Where(u => u.userId == userId);
return new
{
userPref,
userOptions
};
}
我知道我可以访问原始数据,这很棒。但除此之外,实体是在实体管理器中创建的,我不希望它们是这样。这适用于 return IQueryable 的 api。 returns 多个结果集的 web api 的 noTracking 是否有不同的语法?
感谢
我无法重现您描述的错误。我有 a similar DocCode test that passes 引用了 Breeze v1.5.3.
这里是 pertinent NorthwindController method:
[HttpGet]
public object Lookups()
{
var regions = _repository.Regions;
var territories = _repository.Territories;
var categories = _repository.Categories;
var lookups = new { regions, territories, categories };
return lookups;
}
这是通过的 QUnit 测试:
asyncTest('object query (e.g., lookups) w/ "no tracking" does not add to cache', function () {
expect(2);
var em = newNorthwindEm();
EntityQuery.from('Lookups')
.noTracking(true)
.using(em).execute()
.then(success).fail(handleFail).fin(start);
function success(data) {
var lookups = data.results[0];
var hasLookups = lookups &&
lookups.categories && lookups.regions && lookups.territories;
ok(hasLookups, 'Expected a lookups object w/ categories, regions and territories');
var cached = em.getEntities();
var len = cached.length;
equal(0, len, 'Expected ZERO cached entities of any kind and got ' + len);
}
});
如果我注释掉 noTracking(true)
子句,测试将失败并告诉我缓存中有 65 个实体......正如预测的那样。
我错过了什么?
考虑这个简单的查询:
return EntityQuery.from('myAPI')
.noTracking(true)
.using(manager).execute()
.then(querySucceeded)
.fail(queryFailed);
我的API是这样定义的:
[HttpGet]
public object myAPI()
{
// var userId = get the users id from auth ticket
var userPref = _contextProvider.Context.UserPreferences.Where(u => u.userId == userId);
var userOptions = _contextProvider.Context.UserOptions.Where(u => u.userId == userId);
return new
{
userPref,
userOptions
};
}
我知道我可以访问原始数据,这很棒。但除此之外,实体是在实体管理器中创建的,我不希望它们是这样。这适用于 return IQueryable 的 api。 returns 多个结果集的 web api 的 noTracking 是否有不同的语法?
感谢
我无法重现您描述的错误。我有 a similar DocCode test that passes 引用了 Breeze v1.5.3.
这里是 pertinent NorthwindController method:
[HttpGet]
public object Lookups()
{
var regions = _repository.Regions;
var territories = _repository.Territories;
var categories = _repository.Categories;
var lookups = new { regions, territories, categories };
return lookups;
}
这是通过的 QUnit 测试:
asyncTest('object query (e.g., lookups) w/ "no tracking" does not add to cache', function () {
expect(2);
var em = newNorthwindEm();
EntityQuery.from('Lookups')
.noTracking(true)
.using(em).execute()
.then(success).fail(handleFail).fin(start);
function success(data) {
var lookups = data.results[0];
var hasLookups = lookups &&
lookups.categories && lookups.regions && lookups.territories;
ok(hasLookups, 'Expected a lookups object w/ categories, regions and territories');
var cached = em.getEntities();
var len = cached.length;
equal(0, len, 'Expected ZERO cached entities of any kind and got ' + len);
}
});
如果我注释掉 noTracking(true)
子句,测试将失败并告诉我缓存中有 65 个实体......正如预测的那样。
我错过了什么?