Example #1
0
        public static T SingleWithCache <T>(Expression <Func <T, bool> > predictate, params Expression <Func <T, object> >[] includes) where T : class, IEntity
        {
            var lpredict = predictate;
            var key      = ObjectCloner.DataHash(includes);
            var ci       = GetFromCache(lpredict, key);

            if (ci != null)
            {
                return(ci);
            }

            using (var workspace = WorkspaceFactory.CreateReadOnly())
            {
                var result = workspace.Single(lpredict, includes);
                AddToCache(key, result);
                return(result);
            }
        }