示例#1
0
        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);
        }
示例#2
0
 public System.Collections.Generic.ISet <T> GetResultSet <T>()
 {
     Net.Vpc.Upa.Query q = Build();
     return(q.GetResultSet <T>());
 }
示例#3
0
 public System.Collections.Generic.IList <R2> GetResultList <R2>() /* throws Net.Vpc.Upa.Exceptions.UPAException */
 {
     Net.Vpc.Upa.Query q = Build();
     return(q.GetResultList <T>());
 }
示例#4
0
        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);
        }