private static int GetCustomersViaSpRaw(ISisoDatabase database, int customerNoFrom, int customerNoTo) { using (var session = database.BeginSession()) { var q = new NamedQuery("CustomersViaSP"); q.Add(new DacParameter("p0", customerNoFrom)); q.Add(new DacParameter("p1", customerNoTo)); q.Add(new DacParameter("p2", "The delivery street #544")); return(session.Advanced.NamedQuery <Customer>(q).ToArray().Length); } }
public virtual IEnumerable <T> NamedQuery <T>(string name, Expression <Func <T, bool> > predicate) where T : class { return(Try(() => { var queryBuilder = Db.ProviderFactory.GetQueryBuilder <T>(Db.StructureSchemas); queryBuilder.Where(predicate); var query = queryBuilder.Build(); var sqlExpression = SqlExpressionBuilder.Process(query); var namedQuery = new NamedQuery(name); namedQuery.Add(sqlExpression.WhereCriteria.Parameters); return OnNamedQueryAs <T, T>(namedQuery); })); }