Esempio n. 1
0
        public static void LoadEntitySetWithFilter(ILoadEntitySetWithFilter <TEntity> msg)
        {
            try
            {
                using (var ctx = new TDBContext())
                {
                    var loggerFactory = ctx.GetService <ILoggerFactory>();
                    loggerFactory.AddProvider(new MyLoggerProvider());


                    IQueryable <TDBEntity> rres = ctx.Set <TDBEntity>().AsNoTracking();
                    if (rres == null)
                    {
                        return;
                    }


                    var rfilter = msg.Filter.Select(ExpressionConverter <TEntity> .ConvertExpressionType <TDBEntity, bool>).ToList();
                    rres = rfilter?.Aggregate(rres, (current, s) => current.Where(s));


                    var res = rres.OrderByDescending(x => x.Id).Select(x => (TEntity)(object)x).ToList();
                    EventMessageBus.Current.Publish(new EntitySetWithFilterLoaded <TEntity>(res, new StateEventInfo(msg.Process.Id, RevolutionData.Context.Entity.Events.EntitySetLoaded), msg.Process, Source), Source);
                }
            }
            catch (Exception ex)
            {
                PublishProcesError(msg, ex, typeof(IEntitySetWithFilterLoaded <TEntity>));
            }
        }
Esempio n. 2
0
 public static void LoadEntitySetWithFilter(ILoadEntitySetWithFilter <TEntity> msg)
 {
     typeof(EntityRepository <, ,>).MakeGenericType(typeof(TEntity), EntityType, ctxType)
     .GetMethod("LoadEntitySetWithFilter")
     .Invoke(null, new object[] { msg });
 }
Esempio n. 3
0
 public static void LoadEntitySet <TEntity>(this ILoadEntitySetWithFilter <TEntity> msg)
     where TEntity : class, IEntity
 {
     EF7DataContext <TEntity> .LoadEntitySetWithFilter(msg);
 }