小编典典

Breeze.js-尝试使用“ ny”运算符时出错-错误:无法获取属性'isAnonymous'的值:对象为null或未定义

sql

我试图在Breeze中使用“ any”运算符来查询多个表,并且出现以下错误-
TypeError:无法获取属性’isAnonymous’的值:对象为null或未定义

我可以发现的唯一与此相关的stackoverflow问题是这个问题,但是没有对isAnonymous问题的解决方案,因为发布者未提供更多代码:

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

我在实体框架5中使用Breeze 1.4.11

我正在尝试运行的查询是

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

其中“ this”是来自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);
            });
        }
    };

阅读 184

收藏
2021-04-28

共1个答案

小编典典

这看起来像资源名称问题。我的猜测是您尚未建立资源名称/实体类型映射。

2021-04-28