public virtual string GetNewValue(Net.Vpc.Upa.Field field) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Entity entity = field.GetEntity(); string idName = field.GetName(); string goodId = null; for (int i = 0; i < asynchNbrTry; i++) { System.Collections.Generic.SortedSet <string> requestedIds = new System.Collections.Generic.SortedSet <string>(); Net.Vpc.Upa.Expressions.InCollection idsSet = new Net.Vpc.Upa.Expressions.InCollection(new Net.Vpc.Upa.Expressions.Var(idName)); for (int j = 0; j < synchNbrTry; j++) { string id = (string)GenerateValue(field); idsSet.Add(new Net.Vpc.Upa.Expressions.Literal(id)); requestedIds.Add(id); } System.Collections.Generic.IList <Net.Vpc.Upa.Record> recordList = entity.CreateQuery((new Net.Vpc.Upa.Expressions.Select()).From(entity.GetName()).Field(new Net.Vpc.Upa.Expressions.Var(idName)).Where(idsSet)).GetRecordList(); System.Collections.Generic.SortedSet <string> foundIds = new System.Collections.Generic.SortedSet <string>(); foreach (Net.Vpc.Upa.Record record in recordList) { foundIds.Add(record.GetString()); } Net.Vpc.Upa.Impl.FwkConvertUtils.SetRemoveRange(requestedIds, foundIds); if ((requestedIds.Count == 0)) { continue; } goodId = Net.Vpc.Upa.Impl.FwkConvertUtils.CollectionSetFirst <string>(requestedIds); break; } return(goodId); }
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); }