Beispiel #1
0
 public DbQueue(EfContextLite ef, DbSet <QueueTask> queueTask, string code, Action <T[], CancellationToken> taskHandler, int packetSize = 1000)
 {
     _ef          = ef;
     _queueTask   = queueTask;
     _queueCode   = code;
     _taskHandler = taskHandler;
     _packetSize  = packetSize;
 }
        public static string GetFromCache(this EfContextLite ef, DbSet <Cache> dbSetCache, string cacheName, Func <JsonKey, string> getter, params object[] args)
        {
            var key     = new JsonKey(args);
            var dbValue = dbSetCache.FirstOrDefault(a => a.Name == cacheName && a.Key == key.Key);

            if (dbValue != null)
            {
                return(dbValue.Value);
            }
            else
            {
                var value = getter(key);
                dbSetCache.AddOrUpdate(new Cache()
                {
                    Name = cacheName, Key = key.Key, Value = value, CreateDate = DateTimeOffset.UtcNow
                });
                ef.SaveChanges();
                return(value);
            }
        }
 public static IEnumerable <T> InsertIfNotExist <T>(this EfContextLite ef, IEnumerable <T> entities, params Expression <Func <T, object> >[] mgrBy) => ef.DbConnection.Merge(entities, mgrBy, update: false);
 public static IEnumerable <T> Merge <T>(this EfContextLite ef, IEnumerable <T> entities, params Expression <Func <T, object> >[] mgrBy) => ef.DbConnection.Merge(entities, mgrBy);
 public static IEnumerable <T> Merge <T>(this EfContextLite ef, T entity, params Expression <Func <T, object> >[] mgrBy) => Merge(ef, ary.Union(entity), mgrBy);