示例#1
0
        public static void LoadEntityViewSetWithChanges(ILoadEntityViewSetWithChanges <TView, IMatchType> msg)
        {
            try
            {
                var exp = FindExpressionClass.FindExpression <TDbEntity, TDbView>();
                using (var ctx = new TDbContext())
                {
                    // ReSharper disable once ReplaceWithSingleCallToFirstOrDefault cuz EF7 bugging LEAVE JUST SO
                    var matchtype = msg.GetType().GenericTypeArguments[1];
                    var whereStr  = msg.Changes.Aggregate("", IMatchTypeFunctions[matchtype]);
                    whereStr = whereStr.TrimEnd('&');
                    IQueryable <TDbView> res;
                    res = string.IsNullOrEmpty(whereStr)
                        ? ctx.Set <TDbEntity>().OrderByDescending(x => x.Id).AsNoTracking().Select(exp)
                        : ctx.Set <TDbEntity>().OrderByDescending(x => x.Id).AsNoTracking().Select(exp).Where(whereStr);


                    EventMessageBus.Current.Publish(new EntityViewSetWithChangesLoaded <TView>(res.Select(x => (TView)(object)x).ToList(), msg.Changes, new StateEventInfo(msg.Process.Id, EntityView.Events.EntityViewFound), msg.Process, Source), Source);
                }
            }
            catch (Exception ex)
            {
                PublishProcesError(msg, ex, typeof(IEntityViewLoaded <TView>));
            }
        }
示例#2
0
 public static void LoadEntityViewSetWithChanges(ILoadEntityViewSetWithChanges <TEntityView, IMatchType> msg)
 {
     typeof(EntityViewRepository <, , , ,>).MakeGenericType(typeof(TEntityView), ViewType, TEntity, EntityType, ctxType)
     .GetMethod("LoadEntityViewSetWithChanges")
     .Invoke(null, new object[] { msg });
 }
 public static void LoadEntityViewSetWithChanges <TEntityView>(this ILoadEntityViewSetWithChanges <TEntityView, IMatchType> msg) where TEntityView : IEntityView
 {
     EntityViewDataContext <TEntityView> .LoadEntityViewSetWithChanges(msg);
 }