问题
Currently playing with John Papa's Hot Towel, I am currently having a strange error:
TypeError: Object [object Object] has no method 'isPartial'
I have been looking into this isPartial thing but without success. All I've done is create a new kind of entity.
I don't know if I should provide more information for this problem. Please help!
Thanks :)
Here's the full error below:
"TypeError: Object [object Object] has no method 'isPartial'
at proto.setProperty (http://localhost:13763/scripts/breeze.debug.js:13153:31)
at http://localhost:13763/scripts/breeze.debug.js:5833:30
at Object.objectForEach (http://localhost:13763/scripts/breeze.debug.js:311:17)
at proto.createEntity (http://localhost:13763/scripts/breeze.debug.js:5832:22)
at proto.createEntity (http://localhost:13763/scripts/breeze.debug.js:9876:18)
at dtoToEntityMapper (http://localhost:13763/App/services/breeze.partial-entities.js:32:38)
at Array.map (native)
at Object.mapDtosToEntities (http://localhost:13763/App/services/breeze.partial-entities.js:23:25)
at querySucceeded (http://localhost:13763/App/services/datacontext.js:64:42)
From previous event:
at Object.getMyEntities (http://localhost:13763/App/services/datacontext.js:60:18)
at Object.activate (http://localhost:13763/App/viewmodels/home.js:6:32)
at activate (http://localhost:13763/App/durandal/viewModel.js:74:38)
at Object.<anonymous> (http://localhost:13763/App/durandal/viewModel.js:231:37)
at Object.<anonymous> (http://localhost:13763/scripts/jquery-1.9.1.min.js:3:9221)
at c (http://localhost:13763/scripts/jquery-1.9.1.min.js:3:7857)
at Object.p.add [as done] (http://localhost:13763/scripts/jquery-1.9.1.min.js:3:8167)
at Array.<anonymous> (http://localhost:13763/scripts/jquery-1.9.1.min.js:3:9198)"
回答1:
Would need more info to diagnose. Is the new type in metadata? Did you create a custom constructor for your type that defines isPartial
, as CCJS does in model.js ~ln #36?
// Pass the Type, Ctor (breeze tracks properties created here), and initializer metadataStore.registerEntityTypeCtor( 'Session', function () { this.isPartial = false; }, sessionInitializer);
You can find out if you've successfully added a property to a type by following this example based on a test method in "entityExtensionTests" of the DocCode sample:
function assertFooPropertyIsUnmappedPropertyOfCustomer(manager) { var custType = manager.metadataStore.getEntityType("Customer"); var fooProp = custType.getDataProperty('foo'); ok(fooProp && fooProp.isUnmapped, "'foo' property should be defined as unmapped property after registration."); }
Btw, in the forthcoming Breeze v.1.3.2 there is much easier way to map partials - flat projections like these - into an EntityType
using EntityQuery.toType()
. You would still need to add isPartial
to the type.
回答2:
I had same issue and I needed to clear my browser cache as it had not got my updated model.js file in which I'd just added a new metadataStore.registerEntityTypeCtor for an entity.
来源:https://stackoverflow.com/questions/16301734/breeze-ispartial