public static FromExpressionInfo AnalyzeFromExpression (
        Expression fromExpression,
        ISqlPreparationStage stage,
        UniqueIdentifierGenerator generator,
        IMethodCallTransformerProvider provider,
        ISqlPreparationContext context,
        Func<ITableInfo, SqlTable> tableGenerator)
    {
      ArgumentUtility.CheckNotNull ("fromExpression", fromExpression);
      ArgumentUtility.CheckNotNull ("stage", stage);
      ArgumentUtility.CheckNotNull ("generator", generator);
      ArgumentUtility.CheckNotNull ("provider", provider);
      ArgumentUtility.CheckNotNull ("context", context);

      var visitor = new SqlPreparationFromExpressionVisitor (generator, stage, provider, context, tableGenerator);
      visitor.VisitExpression (fromExpression);
      if (visitor.FromExpressionInfo != null)
        return visitor.FromExpressionInfo.Value;

      var message = string.Format (
          "Error parsing expression '{0}'. Expressions of type '{1}' cannot be used as the SqlTables of a from clause.",
          FormattingExpressionTreeVisitor.Format (fromExpression),
          fromExpression.Type.Name);
      throw new NotSupportedException (message);
    }
Exemple #2
0
 public LinqProviderComponentFactory()
 {
     // ReSharper disable DoNotCallOverridableMethodsInConstructor
     _resultOperatorHandlerRegistry = CreateResultOperatorHandlerRegistry();
     _methodCallTransformerProvider = CreateMethodCallTransformerProvider();
     // ReSharper restore DoNotCallOverridableMethodsInConstructor
 }
        public static FromExpressionInfo AnalyzeFromExpression(
            Expression fromExpression,
            ISqlPreparationStage stage,
            UniqueIdentifierGenerator generator,
            IMethodCallTransformerProvider provider,
            ISqlPreparationContext context,
            Func <ITableInfo, SqlTable> tableGenerator)
        {
            ArgumentUtility.CheckNotNull("fromExpression", fromExpression);
            ArgumentUtility.CheckNotNull("stage", stage);
            ArgumentUtility.CheckNotNull("generator", generator);
            ArgumentUtility.CheckNotNull("provider", provider);
            ArgumentUtility.CheckNotNull("context", context);

            var visitor = new SqlPreparationFromExpressionVisitor(generator, stage, provider, context, tableGenerator);

            visitor.VisitExpression(fromExpression);
            if (visitor.FromExpressionInfo != null)
            {
                return(visitor.FromExpressionInfo.Value);
            }

            var message = string.Format(
                "Error parsing expression '{0}'. Expressions of type '{1}' cannot be used as the SqlTables of a from clause.",
                FormattingExpressionTreeVisitor.Format(fromExpression),
                fromExpression.Type.Name);

            throw new NotSupportedException(message);
        }
 public IDomainObjectQueryGenerator CreateDomainObjectQueryGenerator(
     StorageProviderDefinition storageProviderDefinition,
     IMethodCallTransformerProvider methodCallTransformerProvider,
     ResultOperatorHandlerRegistry resultOperatorHandlerRegistry,
     IMappingConfiguration mappingConfiguration)
 {
     return(new StubDomainObjectQueryGenerator());
 }
 public IDomainObjectQueryGenerator CreateDomainObjectQueryGenerator(
     StorageProviderDefinition storageProviderDefinition,
     IMethodCallTransformerProvider methodCallTransformerProvider,
     ResultOperatorHandlerRegistry resultOperatorHandlerRegistry,
     IMappingConfiguration mappingConfiguration)
 {
     throw new NotImplementedException();
 }
 public TestableSqlPreparationFromExpressionVisitor (
     UniqueIdentifierGenerator generator,
     ISqlPreparationStage stage,
     IMethodCallTransformerProvider provider,
     ISqlPreparationContext context,
     Func<ITableInfo, SqlTable> tableGenerator)
     : base (generator, stage, provider, context, tableGenerator)
 {
 }
 public TestableSqlPreparationFromExpressionVisitor(
     UniqueIdentifierGenerator generator,
     ISqlPreparationStage stage,
     IMethodCallTransformerProvider provider,
     ISqlPreparationContext context,
     Func <ITableInfo, SqlTable> tableGenerator)
     : base(generator, stage, provider, context, tableGenerator)
 {
 }
 public void SetUp ()
 {
   _stageMock = MockRepository.GenerateStrictMock<ISqlPreparationStage>();
   _generator = new UniqueIdentifierGenerator();
   _context = SqlStatementModelObjectMother.CreateSqlPreparationContext();
   _methodCallTransformerProvider = CompoundMethodCallTransformerProvider.CreateDefault();
   _visitor = new TestableSqlPreparationFromExpressionVisitor (
       _generator, _stageMock, _methodCallTransformerProvider, _context, info => new SqlTable (info, JoinSemantics.Inner));
 }
 public void SetUp()
 {
     _stageMock = MockRepository.GenerateStrictMock <ISqlPreparationStage>();
     _generator = new UniqueIdentifierGenerator();
     _context   = SqlStatementModelObjectMother.CreateSqlPreparationContext();
     _methodCallTransformerProvider = CompoundMethodCallTransformerProvider.CreateDefault();
     _visitor = new TestableSqlPreparationFromExpressionVisitor(
         _generator, _stageMock, _methodCallTransformerProvider, _context, info => new SqlTable(info, JoinSemantics.Inner));
 }
Exemple #10
0
        protected SqlPreparationExpressionVisitor(
            ISqlPreparationContext context, ISqlPreparationStage stage, IMethodCallTransformerProvider provider)
        {
            ArgumentUtility.CheckNotNull("context", context);
            ArgumentUtility.CheckNotNull("stage", stage);
            ArgumentUtility.CheckNotNull("provider", provider);

            _context = context;
            _stage   = stage;
            _methodCallTransformerProvider = provider;
        }
    protected SqlPreparationExpressionVisitor (
        ISqlPreparationContext context, ISqlPreparationStage stage, IMethodCallTransformerProvider provider)
    {
      ArgumentUtility.CheckNotNull ("context", context);
      ArgumentUtility.CheckNotNull ("stage", stage);
      ArgumentUtility.CheckNotNull ("provider", provider);

      _context = context;
      _stage = stage;
      _methodCallTransformerProvider = provider;
    }
Exemple #12
0
        public void SetUp()
        {
            _stageMock          = MockRepository.GenerateMock <ISqlPreparationStage>();
            _context            = SqlStatementModelObjectMother.CreateSqlPreparationContext();
            _cookMainFromClause = ExpressionHelper.CreateMainFromClause <Cook>();
            _cookQuerySourceReferenceExpression = new QuerySourceReferenceExpression(_cookMainFromClause);
            var source = new UnresolvedTableInfo(_cookMainFromClause.ItemType);

            _sqlTable = new SqlTable(source, JoinSemantics.Inner);
            _context.AddExpressionMapping(new QuerySourceReferenceExpression(_cookMainFromClause), new SqlTableReferenceExpression(_sqlTable));
            _methodCallTransformerProvider = CompoundMethodCallTransformerProvider.CreateDefault();
        }
 protected SqlPreparationFromExpressionVisitor(
     UniqueIdentifierGenerator generator,
     ISqlPreparationStage stage,
     IMethodCallTransformerProvider provider,
     ISqlPreparationContext context,
     Func <ITableInfo, SqlTable> tableGenerator)
     : base(context, stage, provider)
 {
     _generator         = generator;
     FromExpressionInfo = null;
     _tableGenerator    = tableGenerator;
 }
 protected SqlPreparationFromExpressionVisitor (
     UniqueIdentifierGenerator generator,
     ISqlPreparationStage stage,
     IMethodCallTransformerProvider provider,
     ISqlPreparationContext context,
     Func<ITableInfo, SqlTable> tableGenerator)
     : base (context, stage, provider)
 {
   _generator = generator;
   FromExpressionInfo = null;
   _tableGenerator = tableGenerator;
 }
        public void SetUp()
        {
            _stageMock = MockRepository.GenerateStrictMock <ISqlPreparationStage>();
            _generator = new UniqueIdentifierGenerator();
            _context   = SqlStatementModelObjectMother.CreateSqlPreparationContext();
            _methodCallTransformerProvider = CompoundMethodCallTransformerProvider.CreateDefault();

            _someOrderingExtractionPolicy = Some.Item(
                OrderingExtractionPolicy.ExtractOrderingsIntoProjection,
                OrderingExtractionPolicy.DoNotExtractOrderings);

            _tableGenerator = info => new SqlTable(info, JoinSemantics.Inner);
        }
    public DefaultSqlPreparationStage (
        IMethodCallTransformerProvider methodCallTransformerProvider,
        ResultOperatorHandlerRegistry resultOperatorHandlerRegistry,
        UniqueIdentifierGenerator uniqueIdentifierGenerator)
    {
      ArgumentUtility.CheckNotNull ("methodCallTransformerProvider", methodCallTransformerProvider);
      ArgumentUtility.CheckNotNull ("resultOperatorHandlerRegistry", resultOperatorHandlerRegistry);
      ArgumentUtility.CheckNotNull ("uniqueIdentifierGenerator", uniqueIdentifierGenerator);

      _methodCallTransformerProvider = methodCallTransformerProvider;
      _resultOperatorHandlerRegistry = resultOperatorHandlerRegistry;
      _uniqueIdentifierGenerator = uniqueIdentifierGenerator;
    }
Exemple #17
0
        public DefaultSqlPreparationStage(
            IMethodCallTransformerProvider methodCallTransformerProvider,
            ResultOperatorHandlerRegistry resultOperatorHandlerRegistry,
            UniqueIdentifierGenerator uniqueIdentifierGenerator)
        {
            ArgumentUtility.CheckNotNull("methodCallTransformerProvider", methodCallTransformerProvider);
            ArgumentUtility.CheckNotNull("resultOperatorHandlerRegistry", resultOperatorHandlerRegistry);
            ArgumentUtility.CheckNotNull("uniqueIdentifierGenerator", uniqueIdentifierGenerator);

            _methodCallTransformerProvider = methodCallTransformerProvider;
            _resultOperatorHandlerRegistry = resultOperatorHandlerRegistry;
            _uniqueIdentifierGenerator     = uniqueIdentifierGenerator;
        }
    public static Expression TranslateExpression (
        Expression expression,
        ISqlPreparationContext context,
        ISqlPreparationStage stage,
        IMethodCallTransformerProvider provider)
    {
      ArgumentUtility.CheckNotNull ("expression", expression);
      ArgumentUtility.CheckNotNull ("context", context);
      ArgumentUtility.CheckNotNull ("stage", stage);
      ArgumentUtility.CheckNotNull ("provider", provider);

      var visitor = new SqlPreparationExpressionVisitor (context, stage, provider);
      var result = visitor.VisitExpression (expression);
      return result;
    }
Exemple #19
0
        public static Expression TranslateExpression(
            Expression expression,
            ISqlPreparationContext context,
            ISqlPreparationStage stage,
            IMethodCallTransformerProvider provider)
        {
            ArgumentUtility.CheckNotNull("expression", expression);
            ArgumentUtility.CheckNotNull("context", context);
            ArgumentUtility.CheckNotNull("stage", stage);
            ArgumentUtility.CheckNotNull("provider", provider);

            var visitor = new SqlPreparationExpressionVisitor(context, stage, provider);
            var result  = visitor.Visit(expression);

            return(result);
        }
        public ISqlQueryGenerator CreateSqlQueryGenerator(
            RdbmsProviderDefinition storageProviderDefinition,
            IMethodCallTransformerProvider methodCallTransformerProvider,
            ResultOperatorHandlerRegistry resultOperatorHandlerRegistry)
        {
            ArgumentUtility.CheckNotNull("storageProviderDefinition", storageProviderDefinition);
            ArgumentUtility.CheckNotNull("methodCallTransformerProvider", methodCallTransformerProvider);
            ArgumentUtility.CheckNotNull("resultOperatorHandlerRegistry", resultOperatorHandlerRegistry);

            var persistenceModelProvider = CreateRdbmsPersistenceModelProvider(storageProviderDefinition);

            return(CreateSqlQueryGenerator(
                       storageProviderDefinition,
                       methodCallTransformerProvider,
                       resultOperatorHandlerRegistry,
                       persistenceModelProvider));
        }
        public void SetUp()
        {
            _rdbmsProviderDefinition         = new RdbmsProviderDefinition("TestDomain", new SqlStorageObjectFactory(), "ConnectionString");
            _sqlProviderFactory              = new SqlStorageObjectFactory();
            _persistenceExtensionStub        = MockRepository.GenerateStub <IPersistenceExtension>();
            _storageProviderDefinitionFinder = new StorageGroupBasedStorageProviderDefinitionFinder(DomainObjectsConfiguration.Current.Storage);

            _tableBuilderStub = MockRepository.GenerateStub <TableScriptBuilder> (
                MockRepository.GenerateStub <ITableScriptElementFactory>(), new SqlCommentScriptElementFactory());
            _viewBuilderStub = MockRepository.GenerateStub <ViewScriptBuilder> (
                MockRepository.GenerateStub <IViewScriptElementFactory <TableDefinition> >(),
                MockRepository.GenerateStub <IViewScriptElementFactory <UnionViewDefinition> >(),
                MockRepository.GenerateStub <IViewScriptElementFactory <FilterViewDefinition> >(),
                MockRepository.GenerateStub <IViewScriptElementFactory <EmptyViewDefinition> >(),
                new SqlCommentScriptElementFactory());
            _constraintBuilderStub =
                MockRepository.GenerateStub <ForeignKeyConstraintScriptBuilder> (
                    MockRepository.GenerateStub <IForeignKeyConstraintScriptElementFactory>(), new SqlCommentScriptElementFactory());
            _indexScriptElementFactoryStub = MockRepository.GenerateStub <SqlIndexScriptElementFactory> (
                MockRepository.GenerateStub <ISqlIndexDefinitionScriptElementFactory <SqlIndexDefinition> >(),
                MockRepository.GenerateStub <ISqlIndexDefinitionScriptElementFactory <SqlPrimaryXmlIndexDefinition> >(),
                MockRepository.GenerateStub <ISqlIndexDefinitionScriptElementFactory <SqlSecondaryXmlIndexDefinition> >());
            _indexBuilderStub   = MockRepository.GenerateStub <IndexScriptBuilder> (_indexScriptElementFactoryStub, new SqlCommentScriptElementFactory());
            _synonymBuilderStub =
                MockRepository.GenerateStub <SynonymScriptBuilder> (
                    MockRepository.GenerateStub <ISynonymScriptElementFactory <TableDefinition> >(),
                    MockRepository.GenerateStub <ISynonymScriptElementFactory <UnionViewDefinition> >(),
                    MockRepository.GenerateStub <ISynonymScriptElementFactory <FilterViewDefinition> >(),
                    MockRepository.GenerateStub <ISynonymScriptElementFactory <EmptyViewDefinition> >(),
                    new SqlCommentScriptElementFactory());
            _rdbmsPersistenceModelProviderStub  = MockRepository.GenerateStub <IRdbmsPersistenceModelProvider>();
            _storageTypeInformationProviderStub = MockRepository.GenerateStub <IStorageTypeInformationProvider>();
            _dbCommandBuilderFactoryStub        = MockRepository.GenerateStub <IDbCommandBuilderFactory>();
            MockRepository.GeneratePartialMock <SqlSynonymScriptElementFactory>();
            _storageNameProviderStub = MockRepository.GenerateStub <IStorageNameProvider>();
            _infrastructureStoragePropertyDefinitionProviderStub = MockRepository.GenerateStub <IInfrastructureStoragePropertyDefinitionProvider>();
            _dataStoragePropertyDefinitionFactoryStub            = MockRepository.GenerateStub <IDataStoragePropertyDefinitionFactory>();
            _valueStoragePropertyDefinitonFactoryStub            = MockRepository.GenerateStub <IValueStoragePropertyDefinitionFactory>();
            _relationStoragePropertyDefiniitonFactoryStub        = MockRepository.GenerateStub <IRelationStoragePropertyDefinitionFactory>();
            _methodCallTransformerProviderStub  = MockRepository.GenerateStub <IMethodCallTransformerProvider>();
            _resultOpertatorHandlerRegistryStub = MockRepository.GeneratePartialMock <ResultOperatorHandlerRegistry>();
            _sqlQueryGeneratorStub = MockRepository.GenerateStub <ISqlQueryGenerator>();
            _foreignKeyConstraintDefinitionFactoryStub = MockRepository.GenerateStub <IForeignKeyConstraintDefinitionFactory>();
            _storagePropertyDefinitionResolverStub     = MockRepository.GenerateStub <IStoragePropertyDefinitionResolver>();
        }
Exemple #22
0
        protected SqlPreparationFromExpressionVisitor(
            UniqueIdentifierGenerator generator,
            ISqlPreparationStage stage,
            IMethodCallTransformerProvider provider,
            ISqlPreparationContext context,
            Func <ITableInfo, SqlTable> tableGenerator,
            OrderingExtractionPolicy orderingExtractionPolicy)
            : base(context, stage, provider)
        {
            ArgumentUtility.CheckNotNull("generator", generator);
            ArgumentUtility.CheckNotNull("tableGenerator", tableGenerator);

            _generator                = generator;
            _tableGenerator           = tableGenerator;
            _orderingExtractionPolicy = orderingExtractionPolicy;

            FromExpressionInfo = null;
        }
        public virtual IDomainObjectQueryGenerator CreateDomainObjectQueryGenerator(
            StorageProviderDefinition storageProviderDefinition,
            IMethodCallTransformerProvider methodCallTransformerProvider,
            ResultOperatorHandlerRegistry resultOperatorHandlerRegistry,
            IMappingConfiguration mappingConfiguration)
        {
            var rdmsStorageProviderDefinition =
                ArgumentUtility.CheckNotNullAndType <RdbmsProviderDefinition> ("storageProviderDefinition", storageProviderDefinition);

            ArgumentUtility.CheckNotNull("methodCallTransformerProvider", methodCallTransformerProvider);
            ArgumentUtility.CheckNotNull("resultOperatorHandlerRegistry", resultOperatorHandlerRegistry);
            ArgumentUtility.CheckNotNull("mappingConfiguration", mappingConfiguration);

            var storageTypeInformationProvider = CreateStorageTypeInformationProvider(rdmsStorageProviderDefinition);
            var sqlQueryGenerator = CreateSqlQueryGenerator(rdmsStorageProviderDefinition, methodCallTransformerProvider, resultOperatorHandlerRegistry);

            return(ObjectFactory.Create <DomainObjectQueryGenerator> (
                       ParamList.Create(sqlQueryGenerator, _typeConversionProvider, storageTypeInformationProvider, mappingConfiguration)));
        }
        protected virtual ISqlQueryGenerator CreateSqlQueryGenerator(
            RdbmsProviderDefinition storageProviderDefinition,
            IMethodCallTransformerProvider methodCallTransformerProvider,
            ResultOperatorHandlerRegistry resultOperatorHandlerRegistry,
            IRdbmsPersistenceModelProvider persistenceModelProvider)
        {
            ArgumentUtility.CheckNotNull("storageProviderDefinition", storageProviderDefinition);
            ArgumentUtility.CheckNotNull("methodCallTransformerProvider", methodCallTransformerProvider);
            ArgumentUtility.CheckNotNull("resultOperatorHandlerRegistry", resultOperatorHandlerRegistry);
            ArgumentUtility.CheckNotNull("persistenceModelProvider", persistenceModelProvider);

            var generator           = new UniqueIdentifierGenerator();
            var resolver            = CreateMappingResolver(storageProviderDefinition, persistenceModelProvider);
            var sqlPreparationStage = ObjectFactory.Create <DefaultSqlPreparationStage> (
                ParamList.Create(methodCallTransformerProvider, resultOperatorHandlerRegistry, generator));
            var mappingResolutionStage = ObjectFactory.Create <DefaultMappingResolutionStage> (ParamList.Create(resolver, generator));
            var sqlGenerationStage     = ObjectFactory.Create <ExtendedSqlGenerationStage> (ParamList.Empty);

            return(new SqlQueryGenerator(sqlPreparationStage, mappingResolutionStage, sqlGenerationStage));
        }
 protected override ISqlQueryGenerator CreateSqlQueryGenerator(RdbmsProviderDefinition storageProviderDefinition, IMethodCallTransformerProvider methodCallTransformerProvider, ResultOperatorHandlerRegistry resultOperatorHandlerRegistry, IRdbmsPersistenceModelProvider persistenceModelProvider)
 {
     return(_sqlQueryGenerator ?? base.CreateSqlQueryGenerator(storageProviderDefinition, methodCallTransformerProvider, resultOperatorHandlerRegistry, persistenceModelProvider));
 }
 public ISqlQueryGenerator CreateSqlQueryGenerator(RdbmsProviderDefinition storageProviderDefinition, IMethodCallTransformerProvider methodCallTransformerProvider, ResultOperatorHandlerRegistry resultOperatorHandlerRegistry)
 {
     throw new NotImplementedException();
 }
 public TestableSqlPreparationExpressionVisitorTest(ISqlPreparationContext context, ISqlPreparationStage stage, IMethodCallTransformerProvider provider)
     : base(context, stage, provider)
 {
 }
 public TestableSqlPreparationExpressionVisitorTest (ISqlPreparationContext context, ISqlPreparationStage stage, IMethodCallTransformerProvider provider)
     : base (context, stage, provider)
 {
 }