public SqlCommandGenerateContext Build()
            {
                var parser = new DefaultCommandParser();

                this.context.QueryAttributes = this.context.Method.GetCustomAttributes <SqlAttribute>();

                this.context.HasAnyQueryAttribute = this.context.QueryAttributes != null && this.context.QueryAttributes.Any();

                if (!this.context.HasAnyQueryAttribute)
                {
                    this.context.CommandInfo = parser.Parse(this.context.Method.Name);
                }

                this.context.IDaoType = this.context.Method.DeclaringType;

                IEntityTypeProvider entityTypeProvider = NpiServicesCollection.GetService <IEntityTypeProvider>();

                this.context.EntityType = entityTypeProvider.Provide(this.context.Method);

                ITableNameProvider tableNameProvider = NpiServicesCollection.GetService <ITableNameProvider>();

                this.context.TableName = tableNameProvider.Provide(this.context.EntityType);

                this.context.Properties = this.context.EntityType.GetProperties();


                return(this.context);
            }
Ejemplo n.º 2
0
 public DatabaseContext(DatabaseContextOptions options)
 {
     options_               = options;
     modelDataStorage_      = new ModelDataStorage <Type>();
     dbQueryTranslator_     = new DatabaseCreationQueryTranslator(modelDataStorage_);
     constraintTranslator_  = new ConstraintTranslator(options);
     dbTableToPropertyName_ = new Dictionary <Type, string>();
     stateManager_          = new StateManager(modelDataStorage_);
     database_              = new SqlDatabase(new SqlEntityDeserializer(modelDataStorage_, stateManager_), options_.ConnectionString);
     tableNameProvider_     = new TableNameProvider();
     changeDetector_        = new ChangeDetector(tableNameProvider_, modelDataStorage_);
     updateQueryTranslator_ = new UpdateQueryTranslator(new WhereQueryTranslator());
 }
Ejemplo n.º 3
0
 public ChangeDetector(ITableNameProvider tableNameProvider, IModelDataStorage <Type> modelDataStorage)
 {
     tableNameProvider_ = tableNameProvider;
     modelDataStorage_  = modelDataStorage;
 }