Creates a new Query without a static type.
This method is used when generating queries dynamically from runtime values, where the static type argument cannot be defined. Behaves just like the unnamed constructor.
If entity
is not in context
's ManagedContext.dataModel, throws a internal failure QueryException.
Source
factory Query.forEntity(ManagedEntity entity, [ManagedContext context]) { var ctx = context ?? ManagedContext.defaultContext; if (!ctx.dataModel.entities.any((e) => identical(entity, e))) { throw new QueryException( QueryExceptionEvent.internalFailure, message: "Cannot instantiate Query.withEntity, entity/context mismatch"); } return ctx.persistentStore.newQuery<InstanceType>(ctx, entity); }