Breeze.js - 尝试使用“any”时收到错误operator - error:无法获取属性'isAnonymous'的值:object为null或undefined [英] Breeze.js - getting error trying to use "any" operator - error: Unable to get value of the property 'isAnonymous': object is null or undefined

查看:193
本文介绍了Breeze.js - 尝试使用“any”时收到错误operator - error:无法获取属性'isAnonymous'的值:object为null或undefined的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Breeze中的any运算符来查询许多表,我收到以下错误 - TypeError:无法获取属性'isAnonymous'的值:object is null或undefined

I am trying to use the "any" operator in Breeze to query a many table and I am getting the following error - TypeError: Unable to get value of the property 'isAnonymous': object is null or undefined

我能找到的唯一一个看似相关的stackoverflow问题是这个问题,但isAnonymous问题没有解决办法,因为海报没有提供更多的代码:

The only stackoverflow question I can find that seems related is this one, but there is no solution to the isAnonymous issue because the poster did not provide more code:

微风投影:错误选择非标量导航属性

我使用Breeze 1.4.11和
实体框架5

I am using Breeze 1.4.11 with Entity Framework 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 on entity_sys_key_id ...他们是视图......这里是视图定义

t_entity joins to t_entity_nm on entity_sys_key_id...they are views...here are the view definitions

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]

Breeze控制器如下所示:

The Breeze Controller looks like this:

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 - >

The code where it is breaking is in breeze.debug.js on the line ->

if (entityType.isAnonymous) return;

其中this是breeze.debug.js的以下代码片段中的frst_nm字段:

where "this" is the frst_nm field in the following code snippet from breeze.debug.js:

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);
            });
        }
    };


推荐答案

这看起来像资源名称问题。我的猜测是你还没有建立资源名称/实体类型映射。

This looks like a resource name issue. My guess is that you have not established a resource name/entity type mapping.

看一下这些链接:

http://www.breezejs.com/documentation/query-result-debugging

http://www.breezejs.com/sites/all /apidocs/classes/MetadataStore.html#method_setEntityTypeForResourceName

这一个: http://www.breezejs.com/documentation/querying-locally 子主题下的
资源名称不是实体类型名称

这篇关于Breeze.js - 尝试使用“any”时收到错误operator - error:无法获取属性'isAnonymous'的值:object为null或undefined的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆