public virtual Net.Vpc.Upa.Record KeyToRecord(Net.Vpc.Upa.Key key) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { if (key == null) { return(null); } Net.Vpc.Upa.Record ur = CreateRecord(); System.Collections.Generic.IList <Net.Vpc.Upa.Field> primaryFields = GetEntity().GetPrimaryFields(); if (key == null) { foreach (Net.Vpc.Upa.Field aF in primaryFields) { ur.SetObject(aF.GetName(), null); } } else { object[] uk = key.GetValue(); for (int i = 0; i < (primaryFields).Count; i++) { ur.SetObject(primaryFields[i].GetName(), uk[i]); } } return(ur); }
public override string GetDescription() { if (desc == null) { try { Net.Vpc.Upa.Entity _entity = GetEntity(); Net.Vpc.Upa.Key ukey = _entity.GetBuilder().IdToKey(key); System.Collections.Generic.IList <Net.Vpc.Upa.Field> f = _entity.GetPrimaryFields(); System.Text.StringBuilder descsb = new System.Text.StringBuilder(); object[] values = ukey.GetValue(); for (int i = 0; i < (f).Count; i++) { if (i > 0) { descsb.Append(" "); descsb.Append(" and "); descsb.Append(" "); } if (values[i] == null) { descsb.Append(f[i].GetI18NString()).Append(" undefined operator "); } else { descsb.Append(f[i].GetI18NString()).Append(" = ").Append(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral(values[i], Net.Vpc.Upa.Impl.Util.UPAUtils.GetTypeTransformOrIdentity(f[i])).ToString()); } } desc = descsb.ToString(); } catch (Net.Vpc.Upa.Exceptions.UPAException ex) { desc = ""; } } return(desc); }
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 virtual object KeyToObject(Net.Vpc.Upa.Key key) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { if (key == null) { return(null); } return(ObjectToRecord(KeyToRecord(key))); }
public virtual object KeyToId(Net.Vpc.Upa.Key uk) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { if (uk == null) { return(null); } return(GetEntity().GetBuilder().GetId(uk)); }
public virtual object GetId(Net.Vpc.Upa.Key unstructuredKey) { if (unstructuredKey == null) { return(null); } return(CreateId(unstructuredKey.GetValue())); }
public virtual object GetId(Net.Vpc.Upa.Key unstructuredKey) { if (nfo.GetPlatformType().IsInstanceOfType(unstructuredKey)) { return(unstructuredKey); } Net.Vpc.Upa.Key o = (Net.Vpc.Upa.Key)nfo.NewInstance(); o.SetValue(unstructuredKey.GetValue()); return(o); }
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 virtual Net.Vpc.Upa.Expressions.Expression CreateFindImmediateChildrenExpression(string alias, object id) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { System.Collections.Generic.IList <Net.Vpc.Upa.Field> parentFields = GetTreeRelationship().GetSourceRole().GetFields(); Net.Vpc.Upa.Expressions.Expression a = null; Net.Vpc.Upa.Key key = GetEntity().GetBuilder().IdToKey(id); for (int i = 0; i < (parentFields).Count; i++) { Net.Vpc.Upa.Field field = parentFields[i]; Net.Vpc.Upa.Expressions.Var v = new Net.Vpc.Upa.Expressions.Var(alias == null ? null : new Net.Vpc.Upa.Expressions.Var(alias), field.GetName()); Net.Vpc.Upa.Expressions.Expression e = (new Net.Vpc.Upa.Expressions.Equals(v, new Net.Vpc.Upa.Expressions.Literal(key.GetObjectAt(i), field.GetDataType()))); a = a == null ? ((Net.Vpc.Upa.Expressions.Expression)(e)) : new Net.Vpc.Upa.Expressions.And(a, e); } return(a); }
public virtual Net.Vpc.Upa.Expressions.Expression ObjectToIdExpression(object entityOrRecord, string alias) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { if (entityOrRecord == null) { return(null); } Net.Vpc.Upa.Record r = null; if (entityOrRecord is Net.Vpc.Upa.Record) { r = (Net.Vpc.Upa.Record)entityOrRecord; } r = ObjectToRecord(entityOrRecord); Net.Vpc.Upa.Key k = RecordToKey(r); return(KeyToExpression(k, alias)); }
public virtual string ToStringKey(Net.Vpc.Upa.Key key) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { if (key == null) { return(""); } System.Text.StringBuilder s = new System.Text.StringBuilder(); object[] kvalue = key.GetValue(); for (int i = 0; i < kvalue.Length; i++) { if (i > 0) { s.Append(GetHierarchyPathSeparator()); } s.Append(kvalue[i].ToString()); } return(s.ToString()); }
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 BeforePersist(Net.Vpc.Upa.Record record, Net.Vpc.Upa.Persistence.EntityExecutionContext context) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { object o = record.GetObject <T>(field.GetName()); Net.Vpc.Upa.Key key = relationshipTargetConverter.ObjectToKey(o); if (key == null) { foreach (Net.Vpc.Upa.Field ff in flatFields) { record.SetObject(ff.GetName(), ff.GetUnspecifiedValueDecoded()); } } else { int i = 0; foreach (Net.Vpc.Upa.Field ff in flatFields) { record.SetObject(ff.GetName(), key.GetObjectAt(i)); i++; } } }
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 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 object KeyToObject(Net.Vpc.Upa.Key key) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { return(entityFactory.KeyToObject(key)); }
public virtual object GetId(Net.Vpc.Upa.Key unstructuredKey) { return(unstructuredKey); }
public virtual K Convert(Net.Vpc.Upa.Key key) { return((K)entity.GetBuilder().KeyToId(key)); }
public virtual Net.Vpc.Upa.Expressions.Expression KeyToExpression(Net.Vpc.Upa.Key key, string entityAlias) { object id = KeyToId(key); return(IdToExpression(id, entityAlias)); }
public virtual Net.Vpc.Upa.Record KeyToRecord(Net.Vpc.Upa.Key key) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { return(entityFactory.KeyToRecord(key)); }
public virtual object KeyToId(Net.Vpc.Upa.Key recordKey) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { return(entityFactory.KeyToId(recordKey)); }
public virtual Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression TranslateExpression(object x, Net.Vpc.Upa.Impl.Uql.ExpressionTranslationManager manager, Net.Vpc.Upa.Impl.Uql.ExpressionDeclarationList declarations) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Expressions.IdExpression o = (Net.Vpc.Upa.Expressions.IdExpression)x; Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression ret = null; Net.Vpc.Upa.Entity entity = null; if (o.GetEntity() != null) { entity = o.GetEntity(); } Net.Vpc.Upa.PersistenceUnit persistenceUnit = manager.GetPersistenceUnit(); if (entity == null && o.GetEntityName() != null) { entity = persistenceUnit.GetEntity(o.GetEntityName()); } if (entity == null && o.GetAlias() != null) { //check if alias System.Collections.Generic.IList <Net.Vpc.Upa.Impl.Uql.ExpressionDeclaration> dvalues = declarations.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 = persistenceUnit.GetEntity((string)@ref.GetReferrerName()); break; } } } } } if (entity == null && o.GetAlias() != null) { //check if entity if (persistenceUnit.ContainsEntity(o.GetAlias())) { entity = persistenceUnit.GetEntity(o.GetAlias()); } } if (entity == null) { throw new System.ArgumentException("Key enumeration must by associated to and entity"); } Net.Vpc.Upa.Key key = entity.GetBuilder().IdToKey(o.GetId()); object[] values = key == null ? null : key.GetValue(); Net.Vpc.Upa.Entity entity1 = o.GetEntity(); System.Collections.Generic.IList <Net.Vpc.Upa.PrimitiveField> f = entity1.ToPrimitiveFields <Net.Vpc.Upa.Field>(entity1.GetPrimaryFields()); for (int i = 0; i < (f).Count; i++) { Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar ppp = o.GetAlias() == null ? null : new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar(o.GetAlias()); if (ppp == null) { ppp = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar(f[i].GetName()); } else { ppp.SetChild(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar(f[i].GetName())); } Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEquals e = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEquals(ppp, new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledLiteral(values == null ? null : values[i], Net.Vpc.Upa.Impl.Util.UPAUtils.GetTypeTransformOrIdentity(f[i]))); ret = (ret == null) ? ((Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression)(e)) : new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledAnd(ret, e); } if (ret == null) { ret = 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(1)); } return(ret); }
public virtual Net.Vpc.Upa.Expressions.Expression GetSourceCondition(Net.Vpc.Upa.Expressions.Expression targetCondition, string sourceAlias, string targetAlias) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { //Key Rkey=getTargetTable().getKeyForExpression(targetCondition); Net.Vpc.Upa.Field[] sourceFields = GetSourceRole().GetFields().ToArray(); Net.Vpc.Upa.Field[] targetFields = GetTargetRole().GetFields().ToArray(); if (targetCondition is Net.Vpc.Upa.Expressions.IdExpression) { Net.Vpc.Upa.Key Rkey = targetRole.GetEntity().GetBuilder().IdToKey(((Net.Vpc.Upa.Expressions.IdExpression)targetCondition).GetId()); if (sourceFields.Length == 1) { Net.Vpc.Upa.Expressions.Var lvar = (sourceAlias == null) ? new Net.Vpc.Upa.Expressions.Var(sourceFields[0].GetName()) : new Net.Vpc.Upa.Expressions.Var(new Net.Vpc.Upa.Expressions.Var(sourceAlias), sourceFields[0].GetName()); return(new Net.Vpc.Upa.Expressions.Equals(lvar, new Net.Vpc.Upa.Expressions.Literal(Rkey == null ? null : Rkey.GetValue()[0], targetFields[0].GetDataType()))); } else { Net.Vpc.Upa.Expressions.Expression a = null; for (int i = 0; i < sourceFields.Length; i++) { Net.Vpc.Upa.Expressions.Var lvar = (sourceAlias == null) ? new Net.Vpc.Upa.Expressions.Var(sourceFields[i].GetName()) : new Net.Vpc.Upa.Expressions.Var(new Net.Vpc.Upa.Expressions.Var(sourceAlias), sourceFields[i].GetName()); Net.Vpc.Upa.Expressions.Expression rvar = new Net.Vpc.Upa.Expressions.Literal(Rkey == null ? null : Rkey.GetObjectAt(i), targetFields[i].GetDataType()); Net.Vpc.Upa.Expressions.Expression e = new Net.Vpc.Upa.Expressions.Equals(lvar, rvar); a = a == null ? e : a; } return(a); } } else if (tuningMaxInline > 0) { Net.Vpc.Upa.Expressions.Var[] lvar = new Net.Vpc.Upa.Expressions.Var[sourceFields.Length]; Net.Vpc.Upa.Expressions.Var[] rvar = new Net.Vpc.Upa.Expressions.Var[targetFields.Length]; for (int i = 0; i < lvar.Length; i++) { lvar[i] = new Net.Vpc.Upa.Expressions.Var((sourceAlias == null) ? null : new Net.Vpc.Upa.Expressions.Var(sourceAlias), sourceFields[i].GetName()); rvar[i] = new Net.Vpc.Upa.Expressions.Var((targetAlias == null) ? null : new Net.Vpc.Upa.Expressions.Var(targetAlias), targetFields[i].GetName()); } try { System.Collections.Generic.IList <Net.Vpc.Upa.Record> list = GetTargetRole().GetEntity().CreateQuery(new Net.Vpc.Upa.Expressions.Select().Uplet(rvar, "rval").Where(targetCondition)).GetRecordList(); int j = 0; Net.Vpc.Upa.Expressions.IdCollectionExpression inCollection = new Net.Vpc.Upa.Expressions.IdCollectionExpression(lvar); foreach (Net.Vpc.Upa.Record r in list) { j++; if (j > tuningMaxInline) { return(new Net.Vpc.Upa.Expressions.InSelection(lvar, new Net.Vpc.Upa.Expressions.Select().From(GetTargetRole().GetEntity().GetName()).Uplet(rvar).Where(targetCondition))); } inCollection.Add(new Net.Vpc.Upa.Expressions.Param(null, r.GetSingleResult <T>())); } //inCollection.add(new Litteral(rs.getObject(1))); return(inCollection); } catch (Net.Vpc.Upa.Exceptions.UPAException e) { return(new Net.Vpc.Upa.Expressions.InSelection(lvar, new Net.Vpc.Upa.Expressions.Select().From(GetTargetRole().GetEntity().GetName()).Uplet(rvar).Where(targetCondition))); } } else { Net.Vpc.Upa.Expressions.Var[] lvar = new Net.Vpc.Upa.Expressions.Var[sourceFields.Length]; Net.Vpc.Upa.Expressions.Var[] rvar = new Net.Vpc.Upa.Expressions.Var[targetFields.Length]; for (int i = 0; i < lvar.Length; i++) { lvar[i] = new Net.Vpc.Upa.Expressions.Var((sourceAlias == null) ? null : new Net.Vpc.Upa.Expressions.Var(sourceAlias), sourceFields[i].GetName()); rvar[i] = new Net.Vpc.Upa.Expressions.Var((targetAlias == null) ? null : new Net.Vpc.Upa.Expressions.Var(targetAlias), targetFields[i].GetName()); } return(new Net.Vpc.Upa.Expressions.InSelection(lvar, new Net.Vpc.Upa.Expressions.Select().From(GetTargetRole().GetEntity().GetName()).Uplet(rvar).Where(targetCondition))); } }
public virtual void SetKey(Net.Vpc.Upa.Key key) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Record kr = GetEntity().GetBuilder().KeyToRecord(key); GetRecord().SetAll(kr); }
public virtual object CreateId(params object [] keyValues) { Net.Vpc.Upa.Key o = (Net.Vpc.Upa.Key)nfo.NewInstance(); o.SetValue(keyValues); return(o); }
public virtual Net.Vpc.Upa.Expressions.Expression KeyToExpression(Net.Vpc.Upa.Key recordKey, string alias) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { return(entityFactory.KeyToExpression(recordKey, alias)); }
public Net.Vpc.Upa.QueryBuilder ByKey(Net.Vpc.Upa.Key key) { this.key = key; return(this); }
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 static Net.Vpc.Upa.RemoveOptions ForKey(Net.Vpc.Upa.Key expr) { return(new Net.Vpc.Upa.RemoveOptions(Net.Vpc.Upa.ConditionType.KEY, expr)); }
public virtual object GetId(Net.Vpc.Upa.Key unstructuredKey) { return(keyFactory.GetId(unstructuredKey)); }