protected TDataType Find(NHookedContext ctx, Expression <Func <TDataType, bool> > expr) { IQueryable <TDataType> query = SetAccessor(ctx); query = LoadingIncludes().Aggregate(query, (q, s) => q.Include(s)); return(query.FirstOrDefault(expr)); }
public T InContext <T>(Func <NHookedContext, T> f) { T result = default(T); using (NHookedContext ctx = new NHookedContext()) { result = f(ctx); } return(result); }
public void InContext(Action <NHookedContext> f) { using (NHookedContext ctx = new NHookedContext()) { f(ctx); } }
private PersistentUnit GetUnit(NHookedContext ctx) { // The order by looks superfluous but is not; changes between 2008 and 2012 mean that ordering reverts to what was originally intended for RDBMS - no guaranteed ordering return ctx.PersistentUnits.Where(u => u.Subscription.UniqueId == Prototype.Subscription.UniqueId).OrderBy(u => u.PersistentUnitId).FirstOrDefault(); }
protected override void PreCommit(NHookedContext ctx, PersistentSubscription obj) { var topic = ctx.Topics.FirstOrDefault(t => t.UniqueId == obj.Topic.UniqueId); topic.IsNotNull(() => obj.Topic = topic); }
protected virtual void PreCommit(NHookedContext ctx, TDataType obj) { }
private PersistentUnit GetUnit(NHookedContext ctx) { // The order by looks superfluous but is not; changes between 2008 and 2012 mean that ordering reverts to what was originally intended for RDBMS - no guaranteed ordering return(ctx.PersistentUnits.Where(u => u.Subscription.UniqueId == Prototype.Subscription.UniqueId).OrderBy(u => u.PersistentUnitId).FirstOrDefault()); }