我試圖用「任何」運營商在清風查詢很多表和我得到以下錯誤 - TypeError:無法獲取屬性的值'isAnonymous':對象爲空或未定義Breeze.js - 收到錯誤嘗試使用「任何」運營商 - 錯誤:無法獲得屬性「isAnonymous」的值:對象爲空或未定義
唯一的stackoverflow問題,我可以找到似乎相關的是這一個,但沒有解決isAnonymous問題,因爲海報沒有提供更多的代碼:
breeze projection : error selecting non scalar navigation properties
我一個米用微風1.4.11與 實體框架5
我試圖運行查詢是
var getEntities = function (entitiesObservable) {
var whereClause = "";
whereClause = Predicate.create("t_entity_nm", "any", "frst_nm", "startsWith", "Frank");
var query = EntityQuery.from("Entities")
.where(whereClause)
.expand("t_entity_nm");
$('#loading-indicator').show();
return manager.executeQuery(query)
.then(querySucceeded)
.fail(queryFailed);
function querySucceeded(data) {
$('#loading-indicator').hide();
if (entitiesObservable) {
entitiesObservable(data.results);
}
log("Retrieved [Entities] from remote data source", data, true);
}
};
t_entity
加入到t_entity_nm
上entity_sys_key_id
...他們的意見......這裏的視圖定義
CREATE VIEW [dbo].[t_entity]
( [entity_sys_key_id]
, [pers_flag]
, [dob_dt]
, [birth_plc]
, [sin]
, [hsn]
, [drv_lcnc_num]
, [ap_vndr_num]
, [ar_cstmr_num]
, [sec_grp_sys_key_id]
, [actv_flag]
, [log_eff_dt]
, [log_can_dt]
, [log_upd_by]
, [sys_del_flag]
, [sys_ts]
)
AS
SELECT
[entity_sys_key_id]
, [pers_flag]
, [dob_dt]
, [birth_plc]
, [sin]
, [hsn]
, [drv_lcnc_num]
, [ap_vndr_num]
, [ar_cstmr_num]
, [sec_grp_sys_key_id]
, [actv_flag]
, [log_eff_dt]
, [log_can_dt]
, [log_upd_by]
, [sys_del_flag]
, [sys_ts]
FROM [CMN_DEV].[dbo].[t_entity]
CREATE VIEW [dbo].[t_entity_nm]
(
[entity_nm_sys_key_id]
, [entity_sys_key_id]
, [entity_nm_typ_cd]
, [saltn_cd]
, [frst_nm]
, [mid_nm]
, [last_nm]
, [firm_nm]
, [nysiis_key]
, [prmy_flag]
, [sec_grp_sys_key_id]
, [log_eff_dt]
, [log_can_dt]
, [log_upd_by]
, [sys_del_flag]
, [sys_ts]
)
AS
SELECT
[entity_nm_sys_key_id]
, [entity_sys_key_id]
, [entity_nm_typ_cd]
, [saltn_cd]
, [frst_nm]
, [mid_nm]
, [last_nm]
, [firm_nm]
, [nysiis_key]
, [prmy_flag]
, [sec_grp_sys_key_id]
, [log_eff_dt]
, [log_can_dt]
, [log_upd_by]
, [sys_del_flag]
, [sys_ts]
FROM [CMN_DEV].[dbo].[t_entity_nm]
微風控制器看起來是這樣的:
namespace MarketingPromotions.Controllers
{
[BreezeController(MaxAnyAllExpressionDepth = 2)]
public class BreezeController : ApiController
{
readonly EFContextProvider<OASIS_DEVEntities> _contextProvider =
new EFContextProvider<OASIS_DEVEntities>();
[HttpGet]
public string Metadata()
{
return _contextProvider.Metadata();
}
#endregion
[HttpGet]
public IQueryable<t_entity> Entities()
{
return _contextProvider.Context.t_entity;
}
[HttpGet]
public IQueryable<t_entity_nm> EntityNames()
{
return _contextProvider.Context.t_entity_nm;
}
}
的代碼在那裏斷裂是在上線breeze.debug.js - >
if (entityType.isAnonymous) return;
其中「這個」是在從breeze.debug.js下面的代碼段的frst_nm字段:
proto._validate = function(entityType) {
// will throw if not found;
if (this.isValidated) return;
this.isValidated = true;
if (this.propertyPath) {
if (entityType.isAnonymous) return;
var prop = entityType.getProperty(this.propertyPath, true);
if (!prop) {
var msg = __formatString("Unable to resolve propertyPath. EntityType: '%1' PropertyPath: '%2'", entityType.name, this.propertyPath);
throw new Error(msg);
}
if (prop.isDataProperty) {
this.dataType = prop.dataType;
} else {
this.dataType = prop.entityType;
}
} else if (this.fnNodes) {
this.fnNodes.forEach(function(node) {
node._validate(entityType);
});
}
};
你試過執行你的查詢,(因爲它應該被翻譯),直接對EF來確定查詢本身是否工作。 –
我想這對你的建議和它的工作[HTTPGET] 公衆的IQueryable EntitiesByName(){ System.Data.Entity.Infrastructure.DbQuery 查詢= _contextProvider.Context.t_entity; query = query.Include(「t_entity_nm」); return query.Where(e => e.t_entity_nm.Any(en => en.frst_nm.StartsWith(「Frank」))); }然後我看到了關於資源名稱/實體類型映射的其他評論,並且修復了它。 –
user3461612
你能將問題標記爲已回答嗎? (所以我可以把這個從我的名單:) –