Ejemplo n.º 1
0
        static Dictionary <PrimaryKey, string> GetStrings <T>(List <PrimaryKey> ids) where T : Entity
        {
            ICacheController cc = Schema.Current.CacheController(typeof(T));

            if (cc != null && cc.Enabled)
            {
                cc.Load();
                return(ids.ToDictionary(a => a, a => cc.TryGetToString(a)));
            }
            else
            {
                return(ids.GroupsOf(Schema.Current.Settings.MaxNumberOfParameters)
                       .SelectMany(gr =>
                                   Database.Query <T>().Where(e => gr.Contains(e.Id)).Select(a => KVP.Create(a.Id, a.ToString())))
                       .ToDictionary());
            }
        }
Ejemplo n.º 2
0
        public Lite <T> RequestLite <T>(Lite <T> lite) where T : class, IEntity
        {
            if (lite == null)
            {
                return(null);
            }

            ICacheController cc = Schema.Current.CacheController(lite.EntityType);

            if (cc != null && cc.Enabled)
            {
                lite.SetToString(cc.TryGetToString(lite.Id) ?? ("[" + EngineMessage.EntityWithType0AndId1NotFound.NiceToString().FormatWith(lite.EntityType.NiceName(), lite.Id) + "]"));
                return(lite);
            }

            IdentityTuple tuple = new IdentityTuple(lite.EntityType, lite.Id);

            if (liteRequests == null)
            {
                liteRequests = new Dictionary <IdentityTuple, List <Lite <IEntity> > >();
            }
            liteRequests.GetOrCreate(tuple).Add(lite);
            return(lite);
        }