public override IQueryable <TModel> Query(ISession currentSession) { global::NHibernate.ISession nativeSession = GetNativeSession(currentSession); IQueryable <TModel> queryable = nativeSession.Query <TModel>(); return(queryable); }
protected ICriteria GetNativeCriteria(ISession currentSession) { global::NHibernate.ISession nativeSession = GetNativeSession(currentSession); ICriteria criteria = nativeSession.CreateCriteria(modelType); return(criteria); }
public override TModel Update(ISession currentSession, TModel model) { global::NHibernate.ISession nativeSession = GetNativeSession(currentSession); nativeSession.Merge(model); nativeSession.Flush(); return(model); }
public override IQueryable <TModel> GetAll(ISession currentSession) { global::NHibernate.ISession nativeSession = GetNativeSession(currentSession); nativeSession.Clear(); IQueryable <TModel> queryable = Query(currentSession); return(queryable); }
public override IQueryable <TModel> GetByNamedQuery(ISession currentSession, string queryName, IDictionary parameterDictionary) { global::NHibernate.ISession nativeSession = GetNativeSession(currentSession); IQuery query = nativeSession.GetNamedQuery(queryName); query.SetResultTransformer(resultTransformer); return(GetByQuery <TModel>(query, parameterDictionary)); }
public override IQueryable <TModel> GetByQuery(ISession currentSession, string queryString, IDictionary parameterDictionary) { global::NHibernate.ISession nativeSession = GetNativeSession(currentSession); ISQLQuery query = nativeSession.CreateSQLQuery(queryString); query.AddEntity(modelType); return(GetByQuery <TModel>(query, parameterDictionary)); }
public override void Delete(ISession currentSession, IEnumerable <TModel> models) { global::NHibernate.ISession nativeSession = GetNativeSession(currentSession); foreach (TModel model in models) { nativeSession.Delete(model); } nativeSession.Flush(); }
public override IEnumerable <TModel> Update(ISession currentSession, IEnumerable <TModel> models) { global::NHibernate.ISession nativeSession = GetNativeSession(currentSession); foreach (TModel model in models) { nativeSession.Merge(model); } nativeSession.Flush(); return(models); }
public override IQueryable <TModel> GetById <TId>(ISession currentSession, TId id) { global::NHibernate.ISession nativeSession = GetNativeSession(currentSession); nativeSession.Clear(); IClassMetadata classMetadata = nativeSession.SessionFactory.GetClassMetadata(modelType); Expression <Func <TModel, bool> > expression = BuildGetByIdExpression(classMetadata, id); IQueryable <TModel> queryable = Query(currentSession); IQueryable <TModel> result = queryable.Where(expression); return(result); }
private global::NHibernate.ISession GetNativeSession(ISession currentSession) { NHibernateStatefulSession nHibernateStatefulSession = currentSession as NHibernateStatefulSession; global::NHibernate.ISession nativeSession = nHibernateStatefulSession.InnerSession; IClassMetadata classMetadata = nativeSession.SessionFactory.GetClassMetadata(modelType); if (classMetadata == null) { throw new MissingModelMappingException <TModel>(nHibernateStatefulSession); } return(nativeSession); }
public override void Delete(ISession currentSession, TModel model) { global::NHibernate.ISession nativeSession = GetNativeSession(currentSession); nativeSession.Delete(model); nativeSession.Flush(); }