Ejemplo n.º 1
0
        private List <ResultObjectMapping> LoadData(QueryModel queryModel)
        {
            var sqlCommand =
                SqlGeneratorQueryModelVisitor.GenerateSqlQuery(
                    queryModel,
                    Locator,
                    ConverterFactory,
                    ExtensibilityProvider);

            var resultItems = new List <ResultObjectMapping>();

            DatabaseQuery.Execute(sqlCommand.CreateQuery(), dr => resultItems.Add(sqlCommand.ProcessRow(dr)));

            if (queryModel.ResultOperators.Any(it => it is LastResultOperator) && resultItems.Count > 1)
            {
                resultItems.RemoveRange(0, resultItems.Count - 1);
            }
            return(resultItems);
        }
        public static SqlCommandData GenerateSqlQuery(
            QueryModel queryModel,
            IServiceLocator locator,
            IPostgresConverterFactory factory,
            IExtensibilityProvider extensibilityProvider)
        {
            Contract.Requires(queryModel != null);
            Contract.Requires(locator != null);
            Contract.Requires(factory != null);
            Contract.Requires(extensibilityProvider != null);

            var visitor =
                new SqlGeneratorQueryModelVisitor(
                    new MainQueryParts(
                        locator,
                        factory,
                        extensibilityProvider.ResolvePlugins<IQuerySimplification>(),
                        extensibilityProvider.ResolvePlugins<IExpressionMatcher>(),
                        extensibilityProvider.ResolvePlugins<IMemberMatcher>(),
                        extensibilityProvider.ResolvePlugins<IProjectionMatcher>()));
            visitor.VisitQueryModel(queryModel);
            return new SqlCommandData(visitor.QueryParts);
        }
Ejemplo n.º 3
0
        public static SqlCommandData GenerateSqlQuery(
            QueryModel queryModel,
            IServiceLocator locator,
            IPostgresConverterFactory factory,
            IExtensibilityProvider extensibilityProvider)
        {
            Contract.Requires(queryModel != null);
            Contract.Requires(locator != null);
            Contract.Requires(factory != null);
            Contract.Requires(extensibilityProvider != null);

            var visitor =
                new SqlGeneratorQueryModelVisitor(
                    new MainQueryParts(
                        locator,
                        factory,
                        extensibilityProvider.ResolvePlugins <IQuerySimplification>(),
                        extensibilityProvider.ResolvePlugins <IExpressionMatcher>(),
                        extensibilityProvider.ResolvePlugins <IMemberMatcher>(),
                        extensibilityProvider.ResolvePlugins <IProjectionMatcher>()));

            visitor.VisitQueryModel(queryModel);
            return(new SqlCommandData(visitor.QueryParts));
        }