public ComposedToFlatFieldPersister(Net.Vpc.Upa.Field field) { this.field = field; Net.Vpc.Upa.Types.ManyToOneType t = (Net.Vpc.Upa.Types.ManyToOneType)field.GetDataType(); Net.Vpc.Upa.Entity master = t.GetRelationship().GetTargetRole().GetEntity(); Net.Vpc.Upa.RelationshipRole detailRole = t.GetRelationship().GetSourceRole(); flatFields = detailRole.GetFields(); relationshipTargetConverter = master.GetBuilder(); }
public virtual void PrepareFieldForPersist(Net.Vpc.Upa.Field field, object @value, Net.Vpc.Upa.Record userRecord, Net.Vpc.Upa.Record persistentRecord, Net.Vpc.Upa.Persistence.EntityExecutionContext executionContext, System.Collections.Generic.ISet <Net.Vpc.Upa.Field> persistNonNullable, System.Collections.Generic.ISet <Net.Vpc.Upa.Field> persistWithDefaultValue) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Types.ManyToOneType e = (Net.Vpc.Upa.Types.ManyToOneType)field.GetDataType(); if (e.IsUpdatable()) { Net.Vpc.Upa.Entity masterEntity = executionContext.GetPersistenceUnit().GetEntity(e.GetTargetEntityName()); Net.Vpc.Upa.Key k = null; if (@value is Net.Vpc.Upa.Record) { k = masterEntity.GetBuilder().RecordToKey((Net.Vpc.Upa.Record)@value); } else { k = masterEntity.GetBuilder().ObjectToKey(@value); } int x = 0; foreach (Net.Vpc.Upa.Field fk in e.GetRelationship().GetSourceRole().GetFields()) { persistNonNullable.Remove(fk); persistWithDefaultValue.Remove(fk); persistentRecord.SetObject(fk.GetName(), k == null ? null : k.GetObjectAt(x)); x++; } } }
public override string GetSQL(object oo, Net.Vpc.Upa.Persistence.EntityExecutionContext qlContext, Net.Vpc.Upa.Impl.Persistence.SQLManager sqlManager, Net.Vpc.Upa.Impl.Uql.ExpressionDeclarationList declarations) { Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral o = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral)oo; Net.Vpc.Upa.Impl.Util.ExprTypeInfo ei = Net.Vpc.Upa.Impl.Util.UPAUtils.ResolveExprTypeInfo(o); object objectValue = o.GetValue(); Net.Vpc.Upa.Types.DataTypeTransform d = null; if (ei.GetOldReferrer() != null) { Net.Vpc.Upa.Field oldField = (Net.Vpc.Upa.Field)ei.GetOldReferrer(); if (oldField.GetDataType() is Net.Vpc.Upa.Types.ManyToOneType) { Net.Vpc.Upa.Types.ManyToOneType et = (Net.Vpc.Upa.Types.ManyToOneType)oldField.GetDataType(); objectValue = et.GetRelationship().GetTargetEntity().GetBuilder().ObjectToId(objectValue); } } else if (ei.GetReferrer() != null && ei.GetReferrer() is Net.Vpc.Upa.Field) { Net.Vpc.Upa.Field field = (Net.Vpc.Upa.Field)ei.GetReferrer(); if (field.GetDataType() is Net.Vpc.Upa.Types.ManyToOneType) { Net.Vpc.Upa.Types.ManyToOneType et = (Net.Vpc.Upa.Types.ManyToOneType)field.GetDataType(); objectValue = et.GetRelationship().GetTargetEntity().GetBuilder().ObjectToId(objectValue); System.Collections.Generic.IList <Net.Vpc.Upa.Field> tf = et.GetRelationship().GetTargetEntity().GetPrimaryFields(); if ((tf).Count != 1) { throw new System.ArgumentException("Unsupported"); } d = Net.Vpc.Upa.Impl.Util.UPAUtils.GetTypeTransformOrIdentity(tf[0]); } } if (d == null) { d = o.GetEffectiveDataType(); } Net.Vpc.Upa.Impl.Persistence.TypeMarshaller mm = sqlManager.GetMarshallManager().GetTypeMarshaller(d); return(mm.ToSQLLiteral(objectValue)); }
public virtual object GetMainValue(object instance) { object v = GetValue(instance); if (v != null) { Net.Vpc.Upa.Types.DataType d = GetDataType(); if (d is Net.Vpc.Upa.Types.ManyToOneType) { Net.Vpc.Upa.Types.ManyToOneType ed = (Net.Vpc.Upa.Types.ManyToOneType)d; v = ed.GetRelationship().GetTargetEntity().GetBuilder().GetMainValue(v); } } return(v); }
public virtual void Insert(Net.Vpc.Upa.Entity entity, Net.Vpc.Upa.Record originalRecord, Net.Vpc.Upa.Record record, Net.Vpc.Upa.Persistence.EntityExecutionContext context) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.PersistenceUnit pu = context.GetPersistenceUnit(); Net.Vpc.Upa.Expressions.Insert insert = new Net.Vpc.Upa.Expressions.Insert().Into(entity.GetName()); foreach (System.Collections.Generic.KeyValuePair <string, object> entry in record.EntrySet()) { object @value = (entry).Value; string key = (entry).Key; Net.Vpc.Upa.Field field = entity.FindField(key); //should process specific entity fields if ((field.GetDataType() is Net.Vpc.Upa.Types.ManyToOneType)) { Net.Vpc.Upa.Types.ManyToOneType e = (Net.Vpc.Upa.Types.ManyToOneType)field.GetDataType(); if (e.IsUpdatable()) { Net.Vpc.Upa.Entity masterEntity = pu.GetEntity(e.GetTargetEntityName()); Net.Vpc.Upa.Key k = null; if (@value is Net.Vpc.Upa.Record) { k = masterEntity.GetBuilder().RecordToKey((Net.Vpc.Upa.Record)@value); } else { k = masterEntity.GetBuilder().ObjectToKey(@value); } int x = 0; foreach (Net.Vpc.Upa.Field fk in e.GetRelationship().GetSourceRole().GetFields()) { insert.Set(fk.GetName(), new Net.Vpc.Upa.Expressions.Param(fk.GetName(), k.GetObjectAt(x))); x++; } } } else { Net.Vpc.Upa.Expressions.Expression valueExpression = (@value is Net.Vpc.Upa.Expressions.Expression) ? ((Net.Vpc.Upa.Expressions.Expression)((Net.Vpc.Upa.Expressions.Expression)@value)) : new Net.Vpc.Upa.Expressions.Param(field.GetName(), @value); insert.Set(key, valueExpression); } } context.GetPersistenceStore().CreateQuery(insert, context).ExecuteNonQuery(); }
public virtual void Synchronize() { if (field.GetDataType() is Net.Vpc.Upa.Types.ManyToOneType) { Net.Vpc.Upa.Types.ManyToOneType t = (Net.Vpc.Upa.Types.ManyToOneType)field.GetDataType(); Net.Vpc.Upa.Relationship relation = t.GetRelationship(); if (relation == null) { throw new Net.Vpc.Upa.Exceptions.UPAException("MissingRelationForField", field); } Net.Vpc.Upa.RelationshipRole detailRole = relation.GetSourceRole(); Net.Vpc.Upa.RelationshipUpdateType u = detailRole.GetRelationshipUpdateType(); if (u == Net.Vpc.Upa.RelationshipUpdateType.COMPOSED) { persistFieldPersister = new Net.Vpc.Upa.Impl.Persistence.ComposedToFlatFieldPersister(field); updateFieldPersister = new Net.Vpc.Upa.Impl.Persistence.ComposedToFlatFieldPersister(field); } persistFormulaPass = 0; updateFormulaPass = 0; postPersistFormula = false; postUpdateFormula = false; return; } Net.Vpc.Upa.Formula persistFormula = field.GetPersistFormula(); if (persistFormula != null) { if (persistFormula is Net.Vpc.Upa.Sequence) { persistFieldPersister = UpdateFieldPersister(persistFieldPersister, persistenceStore.CreatePersistSequenceGenerator(field)); persistFormulaPass = 0; postPersistFormula = false; } else if (persistFormula is Net.Vpc.Upa.ExpressionFormula) { Net.Vpc.Upa.Impl.Persistence.RebuildExpressionInfo re = RebuildExpression((Net.Vpc.Upa.ExpressionFormula)persistFormula); if (re.rebuiltFormula != null) { field.SetPersistFormula(re.rebuiltFormula); } bool complex = re.compiledExpression.FindFirstExpression <T>(Net.Vpc.Upa.Impl.Uql.Compiledfilters.CompiledExpressionHelper.THIS_VAR_FILTER) != default(T); persistFormulaPass = field.GetPersistFormulaOrder(); if (!complex && persistFormulaPass == 0) { insertExpression = re.expression; persistFieldPersister = UpdateFieldPersister(persistFieldPersister, new Net.Vpc.Upa.Impl.Persistence.ExpressionFieldPersister(field.GetName(), re.expression)); postPersistFormula = false; } else { postPersistFormula = true; } } else { postPersistFormula = true; } } else { postPersistFormula = false; } Net.Vpc.Upa.Formula updateFormula = field.GetUpdateFormula(); if (updateFormula != null) { if (updateFormula is Net.Vpc.Upa.Sequence) { updateFieldPersister = UpdateFieldPersister(updateFieldPersister, persistenceStore.CreateUpdateSequenceGenerator(field)); updateFormulaPass = 0; postUpdateFormula = false; } else if (updateFormula is Net.Vpc.Upa.ExpressionFormula) { Net.Vpc.Upa.Impl.Persistence.RebuildExpressionInfo re = RebuildExpression((Net.Vpc.Upa.ExpressionFormula)persistFormula); if (re.rebuiltFormula != null) { field.SetUpdateFormula(re.rebuiltFormula); } // List<DefaultCompiledExpression> complex = re.compiledExpression.findExpressionsList(CompiledExpressionHelper.THIS_VAR_FILTER); updateFormulaPass = field.GetUpdateFormulaOrder(); if (updateFormulaPass == 0) { updateExpression = re.expression; updateFieldPersister = UpdateFieldPersister(updateFieldPersister, new Net.Vpc.Upa.Impl.Persistence.ExpressionFieldPersister(field.GetName(), re.expression)); postUpdateFormula = false; } else { postUpdateFormula = true; } } else { postUpdateFormula = true; } } else { postUpdateFormula = true; } Net.Vpc.Upa.Formula selectFormula = field.GetSelectFormula(); if (selectFormula != null) { if (selectFormula is Net.Vpc.Upa.ExpressionFormula) { findtExpression = ((Net.Vpc.Upa.ExpressionFormula)selectFormula).GetExpression(); } else if (selectFormula is Net.Vpc.Upa.Sequence) { throw new System.ArgumentException("Sequences are not supported as Select Expressions"); } else if (updateFormula is Net.Vpc.Upa.CustomUpdaterFormula) { throw new System.ArgumentException("CustomUpdaterFormulas are not supported as Select Expressions"); } } }
public virtual Net.Vpc.Upa.Expressions.Expression RecordToExpression(Net.Vpc.Upa.Record record, string alias) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { if (record == null) { return(null); } Net.Vpc.Upa.Expressions.Expression a = null; foreach (System.Collections.Generic.KeyValuePair <string, object> entry in record.EntrySet()) { string key = (entry).Key; object @value = (entry).Value; Net.Vpc.Upa.Field field = GetEntity().GetField(key); if (!field.IsUnspecifiedValue(@value)) { Net.Vpc.Upa.Expressions.Expression e = null; Net.Vpc.Upa.Expressions.Var p = new Net.Vpc.Upa.Expressions.Var(Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty(alias) ? GetEntity().GetName() : alias); switch (field.GetSearchOperator()) { case Net.Vpc.Upa.SearchOperator.DEFAULT: case Net.Vpc.Upa.SearchOperator.EQ: { if (field.GetDataType() is Net.Vpc.Upa.Types.ManyToOneType) { Net.Vpc.Upa.Types.ManyToOneType et = (Net.Vpc.Upa.Types.ManyToOneType)field.GetDataType(); Net.Vpc.Upa.Key foreignKey = et.GetRelationship().GetTargetRole().GetEntity().GetBuilder().ObjectToKey(@value); Net.Vpc.Upa.Expressions.Expression b = null; int i = 0; foreach (Net.Vpc.Upa.Field df in et.GetRelationship().GetSourceRole().GetFields()) { e = new Net.Vpc.Upa.Expressions.Equals(new Net.Vpc.Upa.Expressions.Var((Net.Vpc.Upa.Expressions.Var)p.Copy(), df.GetName()), Net.Vpc.Upa.Expressions.ExpressionFactory.ToLiteral(foreignKey.GetObjectAt(i))); b = b == null ? ((Net.Vpc.Upa.Expressions.Expression)(b)) : new Net.Vpc.Upa.Expressions.And(b, e); i++; } } else { e = new Net.Vpc.Upa.Expressions.Equals(new Net.Vpc.Upa.Expressions.Var(p, key), Net.Vpc.Upa.Expressions.ExpressionFactory.ToLiteral(@value)); } break; } case Net.Vpc.Upa.SearchOperator.NE: { e = new Net.Vpc.Upa.Expressions.Different(new Net.Vpc.Upa.Expressions.Var(p, key), Net.Vpc.Upa.Expressions.ExpressionFactory.ToLiteral(@value)); break; } case Net.Vpc.Upa.SearchOperator.GT: { e = new Net.Vpc.Upa.Expressions.GreaterThan(new Net.Vpc.Upa.Expressions.Var(p, key), Net.Vpc.Upa.Expressions.ExpressionFactory.ToLiteral(@value)); break; } case Net.Vpc.Upa.SearchOperator.GTE: { e = new Net.Vpc.Upa.Expressions.GreaterEqualThan(new Net.Vpc.Upa.Expressions.Var(p, key), Net.Vpc.Upa.Expressions.ExpressionFactory.ToLiteral(@value)); break; } case Net.Vpc.Upa.SearchOperator.LT: { e = new Net.Vpc.Upa.Expressions.LessThan(new Net.Vpc.Upa.Expressions.Var(p, key), Net.Vpc.Upa.Expressions.ExpressionFactory.ToLiteral(@value)); break; } case Net.Vpc.Upa.SearchOperator.LTE: { e = new Net.Vpc.Upa.Expressions.LessEqualThan(new Net.Vpc.Upa.Expressions.Var(p, key), Net.Vpc.Upa.Expressions.ExpressionFactory.ToLiteral(@value)); break; } case Net.Vpc.Upa.SearchOperator.CONTAINS: { e = new Net.Vpc.Upa.Expressions.Like(new Net.Vpc.Upa.Expressions.Var(p, key), Net.Vpc.Upa.Expressions.ExpressionFactory.ToLiteral("%" + @value + "%")); break; } case Net.Vpc.Upa.SearchOperator.STARTS_WITH: { e = new Net.Vpc.Upa.Expressions.Like(new Net.Vpc.Upa.Expressions.Var(p, key), Net.Vpc.Upa.Expressions.ExpressionFactory.ToLiteral(@value + "%")); break; } case Net.Vpc.Upa.SearchOperator.ENDS_WITH: { e = new Net.Vpc.Upa.Expressions.Like(new Net.Vpc.Upa.Expressions.Var(p, key), Net.Vpc.Upa.Expressions.ExpressionFactory.ToLiteral("%" + @value)); break; } } if (e != null) { a = a == null ? ((Net.Vpc.Upa.Expressions.Expression)(e)) : new Net.Vpc.Upa.Expressions.And(a, e); } } } return(a); }
public override string GetSQL(object o, Net.Vpc.Upa.Persistence.EntityExecutionContext qlContext, Net.Vpc.Upa.Impl.Persistence.SQLManager sqlManager, Net.Vpc.Upa.Impl.Uql.ExpressionDeclarationList declarations) { Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledKeyEnumerationExpression ee = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledKeyEnumerationExpression)o; Net.Vpc.Upa.Entity entity = null; Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar compiledVar = null; if (ee.GetAlias() != null) { compiledVar = ee.GetAlias(); entity = (compiledVar.GetReferrer() is Net.Vpc.Upa.Entity) ? ((Net.Vpc.Upa.Entity)compiledVar.GetReferrer()) : null; } else { //check if alias System.Collections.Generic.IList <Net.Vpc.Upa.Impl.Uql.ExpressionDeclaration> dvalues = ee.GetDeclarations(null); if (dvalues != null) { foreach (Net.Vpc.Upa.Impl.Uql.ExpressionDeclaration @ref in dvalues) { switch (@ref.GetReferrerType()) { case Net.Vpc.Upa.Impl.Uql.DecObjectType.ENTITY: { entity = qlContext.GetPersistenceUnit().GetEntity((string)@ref.GetReferrerName()); break; } } } } } if (entity == null) { throw new System.ArgumentException("Key enumeration must by associated to and entity"); } if ((ee.GetKeys().Count == 0)) { return(sqlManager.GetSQL(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEquals(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral(1), new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral(2)), qlContext, declarations)); } System.Collections.Generic.IList <Net.Vpc.Upa.Field> pfs = entity.GetPrimaryFields(); Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression o2 = null; foreach (object key in ee.GetKeys()) { Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression a = null; bool processed = false; if (entity.GetPersistenceUnit().ContainsEntity(entity.GetIdType())) { if (!entity.GetIdType().IsInstanceOfType(key)) { //primitive seen as entity? // A's id is A.b where b is an entity //TODO fix all cases! if ((entity.GetPrimaryFields()).Count == 1) { Net.Vpc.Upa.Types.ManyToOneType et = (Net.Vpc.Upa.Types.ManyToOneType)entity.GetPrimaryFields()[0].GetDataType(); System.Collections.Generic.IList <Net.Vpc.Upa.Field> ff = et.GetRelationship().GetSourceRole().GetFields(); Net.Vpc.Upa.Key key2 = et.GetRelationship().GetTargetEntity().GetBuilder().IdToKey(key); for (int j = 0; j < (ff).Count; j++) { Net.Vpc.Upa.Field f = ff[j]; Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar rr = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar(f); Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar p2 = compiledVar == null ? null : (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar)compiledVar.Copy(); if (p2 == null) { p2 = rr; } else { p2.SetChild(rr); } Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEquals v = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEquals(p2, new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral(key2.GetObjectAt(j), Net.Vpc.Upa.Impl.Util.UPAUtils.GetTypeTransformOrIdentity(f))); if (a == null) { a = v; } else { a = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledAnd(a, v); } } if (o2 == null) { o2 = a; } else { o2 = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledOr(o2, a); } processed = true; } } } if (!processed) { Net.Vpc.Upa.Key uKey = entity.GetBuilder().IdToKey(key); for (int j = 0; j < (pfs).Count; j++) { Net.Vpc.Upa.Field f = pfs[j]; Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar rr = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar(f); Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar p2 = compiledVar == null ? null : (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar)compiledVar.Copy(); if (p2 == null) { p2 = rr; } else { p2.SetChild(rr); } Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEquals v = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEquals(p2, new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral(uKey.GetObjectAt(j), Net.Vpc.Upa.Impl.Util.UPAUtils.GetTypeTransformOrIdentity(f))); if (a == null) { a = v; } else { a = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledAnd(a, v); } } if (o2 == null) { o2 = a; } else { o2 = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledOr(o2, a); } } } return(sqlManager.GetSQL(o2, qlContext, declarations)); }
public virtual int Update(Net.Vpc.Upa.Entity entity, Net.Vpc.Upa.Persistence.EntityExecutionContext context, Net.Vpc.Upa.Record updates, Net.Vpc.Upa.Expressions.Expression condition) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Expressions.Update u = new Net.Vpc.Upa.Expressions.Update().Entity(entity.GetName()); foreach (string fieldName in updates.KeySet()) { Net.Vpc.Upa.Field f = entity.FindField(fieldName); if (f != null && Net.Vpc.Upa.Impl.Util.Filters.Fields2.UPDATE.Accept(f)) { object @value = updates.GetObject <T>(fieldName); if ((f.GetDataType() is Net.Vpc.Upa.Types.ManyToOneType)) { Net.Vpc.Upa.Types.ManyToOneType e = (Net.Vpc.Upa.Types.ManyToOneType)f.GetDataType(); if (e.IsUpdatable()) { Net.Vpc.Upa.Entity masterEntity = context.GetPersistenceUnit().GetEntity(e.GetTargetEntityName()); Net.Vpc.Upa.EntityBuilder mbuilder = masterEntity.GetBuilder(); if (@value is Net.Vpc.Upa.Expressions.Expression) { Net.Vpc.Upa.Expressions.Expression evalue; System.Collections.Generic.IList <Net.Vpc.Upa.Field> sfields = e.GetRelationship().GetSourceRole().GetFields(); System.Collections.Generic.IList <Net.Vpc.Upa.Field> tfields = e.GetRelationship().GetTargetRole().GetFields(); for (int i = 0; i < (sfields).Count; i++) { Net.Vpc.Upa.Field fk = sfields[i]; Net.Vpc.Upa.Field fid = tfields[i]; evalue = ((Net.Vpc.Upa.Expressions.Expression)@value).Copy(); evalue = context.GetPersistenceUnit().GetExpressionManager().ParseExpression(evalue); if (evalue is Net.Vpc.Upa.Expressions.Select) { Net.Vpc.Upa.Expressions.Select svalue = (Net.Vpc.Upa.Expressions.Select)evalue; if (svalue.CountFields() != 1) { throw new System.Exception("Invalid Expression " + svalue + " as formula for field " + f.GetAbsoluteName()); } if (svalue.GetField(0).GetExpression() is Net.Vpc.Upa.Expressions.Var) { svalue.GetField(0).SetExpression(new Net.Vpc.Upa.Expressions.Var((Net.Vpc.Upa.Expressions.Var)svalue.GetField(0).GetExpression(), fid.GetName())); } else { throw new System.Exception("Invalid Expression " + svalue + " as formula for field " + f.GetAbsoluteName()); } } else if (evalue is Net.Vpc.Upa.Expressions.Var) { evalue = (new Net.Vpc.Upa.Expressions.Var((Net.Vpc.Upa.Expressions.Var)evalue, fk.GetName())); } else if (evalue is Net.Vpc.Upa.Expressions.Param) { } else if (evalue is Net.Vpc.Upa.Expressions.Literal) { } else { throw new System.Exception("Invalid Expression " + evalue + " as formula for field " + f.GetAbsoluteName()); } u.Set(fk.GetName(), evalue); } } else { Net.Vpc.Upa.Key k = null; if (@value is Net.Vpc.Upa.Record) { k = mbuilder.RecordToKey((Net.Vpc.Upa.Record)@value); } else { k = mbuilder.ObjectToKey(@value); } int x = 0; foreach (Net.Vpc.Upa.Field fk in e.GetRelationship().GetSourceRole().GetFields()) { u.Set(fk.GetName(), new Net.Vpc.Upa.Expressions.Param(fk.GetName(), k == null ? null : k.GetObjectAt(x))); x++; } } } } else { Net.Vpc.Upa.Expressions.Expression expression = (@value is Net.Vpc.Upa.Expressions.Expression) ? ((Net.Vpc.Upa.Expressions.Expression)((Net.Vpc.Upa.Expressions.Expression)@value)) : new Net.Vpc.Upa.Expressions.Param(null, @value); u.Set(fieldName, expression); } } } u.Where(condition); return(context.GetPersistenceStore().CreateQuery(u, context).ExecuteNonQuery()); }