public static void GetEntityViewById(IGetEntityViewById <TView> msg) { try { var exp = FindExpressionClass.FindExpression <TDbEntity, TDbView>(); using (var ctx = new TDbContext()) { // ReSharper disable once ReplaceWithSingleCallToFirstOrDefault cuz EF7 bugging LEAVE JUST SO var res = ctx.Set <TDbEntity>().AsNoTracking().Select(exp).FirstOrDefault(x => x.Id == msg.EntityId);// EventMessageBus.Current.Publish(new EntityFound <TView>((TView)(object)res, new StateEventInfo(msg.Process.Id, EntityView.Events.EntityViewFound), msg.Process, Source), Source); } } catch (Exception ex) { PublishProcesError(msg, ex, typeof(IEntityFound <TView>)); } }
public static void GetEntityViewById(IGetEntityViewById <TEntityView> msg) { typeof(EntityViewRepository <, , , ,>).MakeGenericType(typeof(TEntityView), ViewType, TEntity, EntityType, ctxType) .GetMethod("GetEntityViewById") .Invoke(null, new object[] { msg }); }
public static void GetEntity <TEntityView>(this IGetEntityViewById <TEntityView> msg) where TEntityView : IEntityView { EntityViewDataContext <TEntityView> .GetEntityViewById(msg); }