public virtual Net.Vpc.Upa.Impl.Persistence.QueryExecutor Execute() /* throws Net.Vpc.Upa.Exceptions.UPAException */ { int c1 = 0; int c2 = 0; string oldAlias = baseExpression.GetEntityAlias(); if (oldAlias == null) { oldAlias = entity.GetName(); } bool replaceThis = !"this".Equals(oldAlias); if (baseExpression.CountFields() > 0) { if (replaceThis) { Net.Vpc.Upa.Impl.Uql.Util.UQLUtils.ReplaceThisVar(baseExpression, oldAlias, context.GetPersistenceUnit()); } c1 = defaultPersistenceStore.CreateDefaultExecutor(baseExpression, parametersByName, parametersByIndex, updatable, defaultFieldFilter, context).Execute().GetResultCount(); } if ((complexVals).Count > 0) { Net.Vpc.Upa.Expressions.Select q = new Net.Vpc.Upa.Expressions.Select(); foreach (Net.Vpc.Upa.Field primaryField in entity.GetPrimaryFields()) { q.Field(primaryField.GetName()); } foreach (Net.Vpc.Upa.Expressions.VarVal f in complexVals) { Net.Vpc.Upa.Expressions.Expression fieldExpression = f.GetVal(); if (replaceThis) { Net.Vpc.Upa.Impl.Uql.Util.UQLUtils.ReplaceThisVar(fieldExpression, oldAlias, context.GetPersistenceUnit()); } q.Field(fieldExpression, f.GetVar().GetName()); } q.From(entity.GetName(), oldAlias); Net.Vpc.Upa.Expressions.Expression cond = baseExpression.GetCondition(); q.SetWhere(cond == null ? null : cond.Copy()); Net.Vpc.Upa.EntityBuilder eb = entity.GetBuilder(); foreach (Net.Vpc.Upa.Record record in entity.GetPersistenceUnit().CreateQuery(q).GetRecordList()) { Net.Vpc.Upa.Expressions.Update u2 = new Net.Vpc.Upa.Expressions.Update(); u2.Entity(entityName); foreach (Net.Vpc.Upa.Expressions.VarVal f in complexVals) { string fname = f.GetVar().GetName(); u2.Set(fname, record.GetObject <T>(fname)); } Net.Vpc.Upa.Expressions.Expression exprId = eb.ObjectToIdExpression(record, oldAlias); u2.Where(exprId); c2 += defaultPersistenceStore.CreateDefaultExecutor(u2, parametersByName, parametersByIndex, updatable, defaultFieldFilter, context).Execute().GetResultCount(); } } resultCount = System.Math.Max(c1, c2); return(this); }
public override void OnCreateEntity(Net.Vpc.Upa.Callbacks.EntityEvent @event) { Net.Vpc.Upa.Entity e = @event.GetEntity(); if (filter.Accept(e)) { if (!added.Contains(e.GetName())) { added.Add(e.GetName()); configurator.Install(e); } } }
public virtual int CompareTo(object other) { if (other == this) { return(0); } if (other == null) { return(1); } Net.Vpc.Upa.Field f = (Net.Vpc.Upa.Field)other; Net.Vpc.Upa.NamingStrategy comp = GetEntity().GetPersistenceUnit().GetNamingStrategy(); string s1 = entity != null?comp.GetUniformValue(entity.GetName()) : ""; string s2 = f.GetName() != null?comp.GetUniformValue(f.GetEntity().GetName()) : ""; int i = s1.CompareTo(s2); if (i != 0) { return(i); } else { string s3 = GetName() != null?comp.GetUniformValue(GetName()) : ""; string s4 = f.GetName() != null?comp.GetUniformValue(f.GetName()) : ""; i = s3.CompareTo(s4); return(i); } }
public virtual void RegisterEntity(Net.Vpc.Upa.Entity item, Net.Vpc.Upa.Package parent) { Net.Vpc.Upa.NamingStrategy namingStrategy = unit.GetNamingStrategy(); string s = item.GetName(); s = namingStrategy.GetUniformValue(s); Net.Vpc.Upa.Entity entity = (Net.Vpc.Upa.Entity)item; entities[s] = item; System.Type entityType = entity.GetEntityType(); if (!entityManagerByEntityTypeAmbiguity.Contains(entityType)) { if (entityManagerByEntityType.ContainsKey(entityType)) { entityManagerByEntityType.Remove(entityType); entityManagerByEntityTypeAmbiguity.Add(entityType); } else { entityManagerByEntityType[entityType] = entity; } } System.Type idType = Net.Vpc.Upa.Impl.Util.PlatformUtils.ToRefType(entity.GetIdType()); if (!entityManagerByIdTypeAmbiguity.Contains(idType)) { if (entityManagerByIdType.ContainsKey(idType)) { entityManagerByIdType.Remove(idType); entityManagerByIdTypeAmbiguity.Add(idType); } else { entityManagerByIdType[idType] = entity; } } }
public virtual void UnregisterEntity(Net.Vpc.Upa.Entity item) { string s = item.GetName(); s = unit.GetNamingStrategy().GetUniformValue(s); entities.Remove(s); }
public virtual void UnregisterField(Net.Vpc.Upa.Field item) { Net.Vpc.Upa.Entity entity = item.GetEntity(); Net.Vpc.Upa.Package module = entity.GetParent(); string s = (module == null ? "/" : module.GetPath() + "/") + entity.GetName() + "/" + item.GetName(); fields.Remove(s); }
public virtual bool ContainsEntity(Net.Vpc.Upa.Entity item, Net.Vpc.Upa.Package parent) { Net.Vpc.Upa.NamingStrategy namingStrategy = unit.GetNamingStrategy(); string s = item.GetName(); s = namingStrategy.GetUniformValue(s); return(entities.ContainsKey(s)); }
public virtual void RegisterSection(Net.Vpc.Upa.Section item) { Net.Vpc.Upa.Entity entity = item.GetEntity(); Net.Vpc.Upa.Package module = entity.GetParent(); string s = (module == null ? "/" : module.GetPath() + "/") + entity.GetName() + "/" + item.GetPath(); sections[s] = item; }
public virtual bool ContainsField(Net.Vpc.Upa.Field item) { Net.Vpc.Upa.Entity entity = item.GetEntity(); Net.Vpc.Upa.Package module = entity.GetParent(); string s = (module == null ? "/" : module.GetPath() + "/") + entity.GetName() + "/" + item.GetName(); return(fields.ContainsKey(s)); }
public virtual Net.Vpc.Upa.QualifiedIdentifier GetViewKey(Net.Vpc.Upa.Entity wiewElementTable, Net.Vpc.Upa.QualifiedIdentifier viewElementKey) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { System.Collections.Generic.IList <Net.Vpc.Upa.Field> fields = GetEntity().GetPrimaryFields(); object[] viewKeyVals = new object[(fields).Count]; object[] elemKeyVals = viewElementKey.GetKey().GetValue(); System.Array.Copy(elemKeyVals, 0, viewKeyVals, 0, elemKeyVals.Length); viewKeyVals[0] = wiewElementTable.GetName(); return(new Net.Vpc.Upa.QualifiedIdentifier(GetEntity(), GetEntity().CreateId(viewKeyVals))); }
public virtual Net.Vpc.Upa.Expressions.Expression GetFullNonUpdatableRecordsExpression() /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Entity parent = entity.GetParentEntity(); Net.Vpc.Upa.Expressions.Expression a = GetNonUpdatableRecordsExpression(); //if hierarchical entity then ignore parent Net.Vpc.Upa.Expressions.Expression b = (parent == null || parent.GetName().Equals(entity.GetName())) ? null : entity.ParentToChildExpression(parent.GetShield().GetFullNonUpdatableRecordsExpression()); a = (a == null) ? ((Net.Vpc.Upa.Expressions.Expression)(b)) : new Net.Vpc.Upa.Expressions.Or(a, b); return((a == null || !a.IsValid()) ? null : a); }
public override string ToString() { System.Text.StringBuilder sb = new System.Text.StringBuilder(entity.GetName()); foreach (Net.Vpc.Upa.EntityPart p in path) { sb.Append("/"); sb.Append(p.GetName()); } return(sb.ToString()); }
public CompiledKeyExpression(Net.Vpc.Upa.Entity entity, object key, string alias) { if (key == null) { throw new System.ArgumentException("Key could not be null"); } // entity.getIdType().cast(key); this.key = key; entityName = entity.GetName(); this.entityAlias = alias; this.entity = entity; }
public IdExpression(Net.Vpc.Upa.Entity entity, object id, string alias) { if (id == null) { throw new System.ArgumentException("Key could not be null"); } // entity.getIdType().cast(key); this.id = id; entityName = entity.GetName(); this.alias = alias; this.entity = entity; }
public DefaultQuery(Net.Vpc.Upa.Expressions.EntityStatement query, Net.Vpc.Upa.Entity defaultEntity, Net.Vpc.Upa.Persistence.EntityExecutionContext context) { this.query = query; if (defaultEntity != null) { if (query is Net.Vpc.Upa.Expressions.Select) { Net.Vpc.Upa.Expressions.Select select = (Net.Vpc.Upa.Expressions.Select)query; if (select.GetEntity() == null) { select.From(defaultEntity.GetName()); } } else if (query is Net.Vpc.Upa.Expressions.Insert) { if (((Net.Vpc.Upa.Expressions.Insert)query).GetEntity() == null) { ((Net.Vpc.Upa.Expressions.Insert)query).Into(defaultEntity.GetName()); } } else if (query is Net.Vpc.Upa.Expressions.Update) { if (((Net.Vpc.Upa.Expressions.Update)query).GetEntity() == null) { ((Net.Vpc.Upa.Expressions.Update)query).Entity(defaultEntity.GetName()); } } else if (query is Net.Vpc.Upa.Expressions.Delete) { if (((Net.Vpc.Upa.Expressions.Delete)query).GetEntity() == null) { ((Net.Vpc.Upa.Expressions.Delete)query).From(defaultEntity.GetName()); } } } this.context = context; // this.cquery = (CompiledEntityStatement) query.copy(); // this.defaultEntity = defaultEntity; store = (Net.Vpc.Upa.Impl.Persistence.DefaultPersistenceStore)context.GetPersistenceStore(); }
public override void OnDropEntity(Net.Vpc.Upa.Callbacks.EntityEvent @event) { Net.Vpc.Upa.Entity e = @event.GetEntity(); if (filter.Accept(e)) { added.Add(e.GetName()); configurator.Uninstall(@event.GetEntity()); if (oneShot && (added).Count == 0) { u.RemoveDefinitionListener(this); } } }
public virtual object LoadObject(Net.Vpc.Upa.Entity e, object id, bool record, Net.Vpc.Upa.Impl.Persistence.Result.LoaderContext context) { Net.Vpc.Upa.NamedId cacheId = new Net.Vpc.Upa.NamedId(id, e.GetName()); Net.Vpc.Upa.Impl.Util.CacheMap <Net.Vpc.Upa.NamedId, object> referencesCache = context.GetReferencesCache(); object existingValue = referencesCache.Get(cacheId); if (existingValue == null && !referencesCache.ContainsKey(cacheId)) { Net.Vpc.Upa.Query query = e.CreateQueryBuilder().ById(id).SetHints(context.GetHints()); existingValue = record ? ((object)(query.GetRecord())) : query.GetEntity <object>(); referencesCache.Put(cacheId, existingValue); } return(existingValue); }
protected internal virtual bool IsDetailOrMasterEntity(Net.Vpc.Upa.Entity e) { string n = e.GetName(); System.Type t = e.GetEntityType(); if (n.Equals(relationDescriptor.GetSourceEntity()) || t.Equals(relationDescriptor.GetSourceEntityType())) { return(true); } if (n.Equals(relationDescriptor.GetTargetEntity()) || t.Equals(relationDescriptor.GetTargetEntityType())) { return(true); } return(false); }
public virtual Net.Vpc.Upa.Expressions.Expression CreateFindEntityByKeyPathExpression(Net.Vpc.Upa.Key[] keyPath, string entityAlias) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Entity entity = GetEntity(); if (entityAlias == null) { entityAlias = entity.GetName(); } System.Text.StringBuilder b = new System.Text.StringBuilder(); foreach (Net.Vpc.Upa.Key o in keyPath) { b.Append(GetHierarchyPathSeparator()); b.Append(ToStringKey(o)); } return(new Net.Vpc.Upa.Expressions.Equals(new Net.Vpc.Upa.Expressions.Var(new Net.Vpc.Upa.Expressions.Var(entityAlias), GetHierarchyPathField()), new Net.Vpc.Upa.Expressions.Param(entityAlias + "_ebip", b.ToString()))); }
private bool ProcessRelation(bool throwErrors) { if (!Build(throwErrors)) { return(false); } Net.Vpc.Upa.PersistenceUnit pu = sourceEntity.GetPersistenceUnit(); if (relation == null) { Net.Vpc.Upa.DefaultRelationshipDescriptor rd = new Net.Vpc.Upa.DefaultRelationshipDescriptor(); rd.SetName(relationDescriptor.GetName()); rd.SetBaseField(relationDescriptor.GetBaseField()); rd.SetRelationshipType(relationDescriptor.GetRelationshipType()); rd.SetSourceEntity(sourceEntity.GetName()); rd.SetTargetEntity(targetEntity.GetName()); rd.SetSourceFields(sourceFieldNames.ToArray()); rd.SetFilter(relationDescriptor.GetFilter()); rd.SetHierarchy(relationDescriptor.IsHierarchy()); rd.SetHierarchyPathField(relationDescriptor.GetHierarchyPathField()); rd.SetHierarchyPathSeparator(relationDescriptor.GetHierarchyPathSeparator()); rd.SetNullable(relationDescriptor.IsNullable()); relation = ((Net.Vpc.Upa.Impl.DefaultPersistenceUnit)pu).AddRelationshipImmediate(rd); } else { if (!Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty(relationDescriptor.GetName())) { relation.SetName(relationDescriptor.GetName()); } relation.SetRelationshipType(relationDescriptor.GetRelationshipType() == default(Net.Vpc.Upa.RelationshipType) ? Net.Vpc.Upa.RelationshipType.DEFAULT : relationDescriptor.GetRelationshipType()); relation.GetSourceRole().SetEntityField(manyToOneField); relation.GetSourceRole().SetRelationshipUpdateType(sourceUpdateType); System.Collections.Generic.IList <Net.Vpc.Upa.Field> slaveFields = new System.Collections.Generic.List <Net.Vpc.Upa.Field>(); foreach (string n in sourceFieldNames) { Net.Vpc.Upa.Field f = sourceEntity.GetField(n); slaveFields.Add(f); } relation.GetSourceRole().SetFields(slaveFields.ToArray()); relation.GetTargetRole().SetEntityField(null); relation.GetTargetRole().SetRelationshipUpdateType(Net.Vpc.Upa.Impl.Util.PlatformUtils.GetUndefinedValue <Net.Vpc.Upa.RelationshipUpdateType>(typeof(Net.Vpc.Upa.RelationshipUpdateType))); relation.SetFilter(filter); relation.SetNullable(nullable); } return(true); }
private void BindRelation(Net.Vpc.Upa.Entity masterEntity) { Net.Vpc.Upa.Types.DataType dataType = field.GetDataType(); if (dataType is Net.Vpc.Upa.Impl.SerializableOrManyToOneType) { field.SetDataType(new Net.Vpc.Upa.Types.ManyToOneType(dataType.GetName(), dataType.GetPlatformType(), masterEntity.GetName(), true, dataType.IsNullable())); field.SetTypeTransform(null); field.SetTypeTransform(new Net.Vpc.Upa.Impl.Transform.IdentityDataTypeTransform(field.GetDataType())); Net.Vpc.Upa.DefaultRelationshipDescriptor relationDescriptor = new Net.Vpc.Upa.DefaultRelationshipDescriptor(); relationDescriptor.SetBaseField(field.GetName()); relationDescriptor.SetTargetEntityType(masterEntity.GetEntityType()); relationDescriptor.SetTargetEntity(masterEntity.GetName()); relationDescriptor.SetSourceEntityType(field.GetEntity().GetEntityType()); relationDescriptor.SetSourceEntity(field.GetEntity().GetName()); field.GetPersistenceUnit().AddRelationship(relationDescriptor); } }
public virtual bool Accept(Net.Vpc.Upa.Entity s) { if (s.GetModifiers().Contains(Net.Vpc.Upa.EntityModifier.SYSTEM)) { if (!includeSystem) { return(false); } } if (name != null) { if (!name.Accept(s.GetName())) { return(false); } } return(true); }
public virtual Net.Vpc.Upa.Expressions.Expression CreateFindEntityByMainPathExpression(string mainFieldPath, string entityAlias) { Net.Vpc.Upa.Entity entity = GetEntity(); Net.Vpc.Upa.RelationshipRole detailRole = GetTreeRelationship().GetSourceRole(); if (Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty(mainFieldPath)) { return(null); } string mainFieldName = entity.GetMainField().GetName(); object mainFieldValue = null; object parent = null; string[] parentAndName = Net.Vpc.Upa.Impl.Util.StringUtils.Split(mainFieldPath, GetHierarchyPathSeparator()[0], false); if (parentAndName != null) { parent = FindEntityByMainPath(parentAndName[0]); mainFieldValue = parentAndName[1]; } else { mainFieldValue = mainFieldPath; } Net.Vpc.Upa.Expressions.Expression expr = null; if (entityAlias == null) { entityAlias = entity.GetName(); } expr = new Net.Vpc.Upa.Expressions.Equals(new Net.Vpc.Upa.Expressions.Var(new Net.Vpc.Upa.Expressions.Var(entityAlias), mainFieldName), mainFieldValue); Net.Vpc.Upa.Key entityToKey = parent == null ? null : entity.GetBuilder().ObjectToKey(parent); System.Collections.Generic.IList <Net.Vpc.Upa.Field> primaryFields = detailRole.GetFields(); for (int index = 0; index < (primaryFields).Count; index++) { Net.Vpc.Upa.Field field = primaryFields[index]; expr = new Net.Vpc.Upa.Expressions.And(expr, new Net.Vpc.Upa.Expressions.Equals(new Net.Vpc.Upa.Expressions.Var(new Net.Vpc.Upa.Expressions.Var(entityAlias), field.GetName()), entityToKey == null ? null : entityToKey.GetObjectAt(index))); } return(expr); }
public virtual object GetValue(string fieldName) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { System.Collections.Generic.IList <Net.Vpc.Upa.Field> f = entity.GetPrimaryFields(); Net.Vpc.Upa.Key uKey = GetKey(); for (int i = 0; i < (f).Count; i++) { if (f[i].GetName().Equals(fieldName)) { return(uKey.GetObjectAt(i)); } } throw new Net.Vpc.Upa.Exceptions.IllegalArgumentException("Either key " + ToString() + " or fieldName " + fieldName + " does not refer to entity " + entity.GetName()); }
public override string GetSQL(object oo, Net.Vpc.Upa.Persistence.EntityExecutionContext context, Net.Vpc.Upa.Impl.Persistence.SQLManager sqlManager, Net.Vpc.Upa.Impl.Uql.ExpressionDeclarationList declarations) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledUpdate o = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledUpdate)oo; Net.Vpc.Upa.Persistence.PersistenceStore persistenceStore = context.GetPersistenceStore(); Net.Vpc.Upa.PersistenceUnit pu = context.GetPersistenceUnit(); Net.Vpc.Upa.Entity entity = pu.GetEntity(o.GetEntity().GetName()); // String persistenceName = persistenceStore.getPersistenceName(entity); System.Text.StringBuilder sb = new System.Text.StringBuilder("Update " + sqlManager.GetSQL(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName(entity.GetName()), context, declarations)); string tableAlias = o.GetEntityAlias(); if (tableAlias != null) { sb.Append(" "); sb.Append(sqlManager.GetSQL(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar(tableAlias), context, declarations)); } sb.Append(" Set "); bool isFirst = true; int max = o.CountFields(); for (int i = 0; i < max; i++) { Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar vv = o.GetField(i); Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar ev = null; Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar fv = null; if (vv.GetChild() == null) { ev = null; fv = vv; } else { ev = vv; fv = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar)vv.GetChild(); } Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression fieldValue = o.GetFieldValue(i); // Object referrer = vv.getReferrer(); Net.Vpc.Upa.Field f = ((Net.Vpc.Upa.Field)fv.GetReferrer()); Net.Vpc.Upa.Entity entityManager = f.GetEntity(); System.Collections.Generic.IList <Net.Vpc.Upa.PrimitiveField> primFields = entityManager.ToPrimitiveFields <Net.Vpc.Upa.EntityPart>(new System.Collections.Generic.List <Net.Vpc.Upa.EntityPart>(new[] { (Net.Vpc.Upa.EntityPart)f })); foreach (Net.Vpc.Upa.PrimitiveField primField in primFields) { if (isFirst) { isFirst = false; } else { sb.Append(", "); } if (ev != null) { sb.Append(sqlManager.GetSQL(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar(ev.GetName()), context, declarations)).Append("."); } sb.Append(sqlManager.GetSQL(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar(primField), context, declarations)); sb.Append("=").Append("(").Append(sqlManager.GetSQL(fieldValue, context, declarations)).Append(")"); } } if (o.GetCondition() != null && o.GetCondition().IsValid()) { sb.Append(" Where ").Append(sqlManager.GetSQL(o.GetCondition(), context, declarations)); } if (persistenceStore.IsViewSupported() && entity.NeedsView() && o.GetEntity().IsUseView()) { string implicitTableAlias = persistenceStore.GetPersistenceName("IT_" + entity.GetName(), Net.Vpc.Upa.Persistence.PersistenceNameType.ALIAS); sb.Append(" "); sb.Append(sqlManager.GetSQL(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName(entity.GetName()), context, declarations)).Append(" ").Append(implicitTableAlias).Append(",").Append(sqlManager.GetSQL(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName(entity.GetName(), true), context, declarations)).Append(" ").Append(sqlManager.GetSQL(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar(tableAlias), context, declarations)); } // if (extraFrom != null) return(sb.ToString()); }
private Net.Vpc.Upa.Query Build() { // if (query == null) { string entityName = entity.GetName(); Net.Vpc.Upa.Expressions.Select s = (new Net.Vpc.Upa.Expressions.Select()).From(entityName, entityAlias); if (GetFieldFilter() != null) { foreach (Net.Vpc.Upa.Field field in entity.GetFields(GetFieldFilter())) { if (field != null) { s.Field(new Net.Vpc.Upa.Expressions.Var(field.GetName()), field.GetName()); } } } Net.Vpc.Upa.Expressions.Expression criteria = null; if (GetId() != null) { Net.Vpc.Upa.Expressions.Expression e = entity.GetBuilder().IdToExpression(GetId(), entityName); criteria = criteria == null ? ((Net.Vpc.Upa.Expressions.Expression)(e)) : new Net.Vpc.Upa.Expressions.And(criteria, e); } if (GetKey() != null) { Net.Vpc.Upa.Expressions.Expression e = (entity.GetBuilder().IdToExpression(entity.GetBuilder().KeyToId(GetKey()), entityName)); criteria = criteria == null ? ((Net.Vpc.Upa.Expressions.Expression)(e)) : new Net.Vpc.Upa.Expressions.And(criteria, e); } if (GetPrototype() != null) { Net.Vpc.Upa.Expressions.Expression e = entity.GetBuilder().ObjectToExpression(GetPrototype(), true, entityName); criteria = criteria == null ? ((Net.Vpc.Upa.Expressions.Expression)(e)) : new Net.Vpc.Upa.Expressions.And(criteria, e); } if (GetRecordPrototype() != null) { Net.Vpc.Upa.Expressions.Expression e = (entity.GetBuilder().RecordToExpression(GetRecordPrototype(), entityName)); criteria = criteria == null ? ((Net.Vpc.Upa.Expressions.Expression)(e)) : new Net.Vpc.Upa.Expressions.And(criteria, e); } if (GetExpression() != null) { Net.Vpc.Upa.Expressions.Expression e = GetExpression(); criteria = criteria == null ? ((Net.Vpc.Upa.Expressions.Expression)(e)) : new Net.Vpc.Upa.Expressions.And(criteria, e); } s.SetWhere(criteria); s.OrderBy(GetOrder()); query = entity.CreateQuery(s); foreach (System.Collections.Generic.KeyValuePair <string, object> e in new System.Collections.Generic.HashSet <System.Collections.Generic.KeyValuePair <string, object> >(paramsByName)) { query.SetParameter((e).Key, (e).Value); } foreach (System.Collections.Generic.KeyValuePair <int?, object> e in new System.Collections.Generic.HashSet <System.Collections.Generic.KeyValuePair <int?, object> >(paramsByIndex)) { query.SetParameter(((e).Key).Value, (e).Value); } query.SetUpdatable(this.IsUpdatable()); if (hints != null) { foreach (System.Collections.Generic.KeyValuePair <string, object> h in new System.Collections.Generic.HashSet <System.Collections.Generic.KeyValuePair <string, object> >(hints)) { query.SetHint((h).Key, (h).Value); } } // } return(query); }
public virtual int Delete(Net.Vpc.Upa.Entity entity, Net.Vpc.Upa.Persistence.EntityExecutionContext context, Net.Vpc.Upa.Expressions.Expression condition, bool recurse, Net.Vpc.Upa.RemoveTrace deleteInfo) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { if (entity.GetShield().IsTransient()) { return(0); } Net.Vpc.Upa.Expressions.Delete stmt = (new Net.Vpc.Upa.Expressions.Delete()).From(entity.GetName()).Where(condition); return(context.GetPersistenceStore().CreateQuery(stmt, context).ExecuteNonQuery()); }
public override void Install(Net.Vpc.Upa.Entity entity, Net.Vpc.Upa.Persistence.EntityOperationManager entityOperationManager, Net.Vpc.Upa.Extensions.EntityExtensionDefinition extension) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { base.Install(entity, entityOperationManager, extension); Net.Vpc.Upa.Extensions.UnionEntityExtensionDefinition e = (Net.Vpc.Upa.Extensions.UnionEntityExtensionDefinition)extension; System.Collections.Generic.IList <object> list = new System.Collections.Generic.List <object>(); foreach (Net.Vpc.Upa.Entity updatableTable in updatableTables) { list.Add(updatableTable.GetName()); } if (discriminator != null) { Net.Vpc.Upa.Field field = GetEntity().AddField(new Net.Vpc.Upa.DefaultFieldDescriptor().SetName(discriminator).SetUserFieldModifiers(Net.Vpc.Upa.FlagSets.Of <E>(Net.Vpc.Upa.UserFieldModifier.SUMMARY)).SetDefaultObject(updatableTables[0].GetName()).SetDataType(Net.Vpc.Upa.Types.TypesFactory.ForList(entity.GetName() + "." + discriminator, list, Net.Vpc.Upa.Types.TypesFactory.STRING, false))); field.SetPersistFormula(new Net.Vpc.Upa.Sequence(Net.Vpc.Upa.SequenceStrategy.AUTO)); } GetPersistenceUnit().AddPersistenceUnitListener(new Net.Vpc.Upa.Impl.Extension.UnionPersistenceUnitInterceptorAdapter(this)); entityOperationManager.SetRemoveOperation(new Net.Vpc.Upa.Impl.Extension.EntityRemoveOperationHelper(this, updatableTables)); }
public virtual int Reset(Net.Vpc.Upa.Entity entity, Net.Vpc.Upa.Persistence.EntityExecutionContext context) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { if (entity.GetShield().IsTransient()) { return(0); } Net.Vpc.Upa.Expressions.Delete stmt = (new Net.Vpc.Upa.Expressions.Delete()).From(entity.GetName()); return(context.GetPersistenceStore().CreateQuery(stmt, context).ExecuteNonQuery()); }
public KeyType(Net.Vpc.Upa.Entity entity, Net.Vpc.Upa.Expressions.Expression filter, bool nullable) : base(entity.GetName(), typeof(Net.Vpc.Upa.Key), ConstructorFieldNames(entity), ConstructorFieldTypes(entity), nullable) { this.entity = entity; this.filter = filter; }