Example #1
0
        public IEnumerable <T> CustomQuery(BaseQuery <T> query)
        {
            var queryInt = (ICustomQuery)query;

            using (new LogAutoStopWatch($"Starting query '{queryInt.Sql}'...", LogLevel.Debug))
            {
                var nhQuery = CreateSqlQuery(query, queryInt);
                return(nhQuery.SetResultTransformer(queryInt.Transformer)
                       .List <T>());
            }
        }
Example #2
0
        public Task <IList <T> > CustomQueryAsync(BaseQuery <T> query, CancellationToken token = default)
        {
            var queryInt = (ICustomQuery)query;

            using (new LogAutoStopWatch($"Starting async query '{queryInt.Sql}'...", LogLevel.Debug))
            {
                var nhQuery = CreateSqlQuery(query, queryInt);
                return(nhQuery.SetResultTransformer(queryInt.Transformer)
                       .ListAsync <T>(token));
            }
        }
Example #3
0
        private ISQLQuery CreateSqlQuery(BaseQuery <T> query, ICustomQuery queryInt)
        {
            var nhQuery = _session.CreateSQLQuery(queryInt.Sql);

            if (query.Parameters == null || !query.Parameters.Any())
            {
                return(nhQuery);
            }

            foreach (var parameter in query.Parameters)
            {
                nhQuery.SetParameter(parameter.Key, parameter.Value);
            }

            return(nhQuery);
        }
Example #4
0
 public TransformerImpl(BaseQuery <T> query)
 {
     _query = query.ThrowIfNull(nameof(query));
 }