protected SqlCeRepositoryBase(IUnitOfWork unitOfWork) : base(unitOfWork) { this.database = DatabaseFactory.CreateDatabase(); this.entityFactory = EntityFactoryBuilder.BuildFactory <T>(); this.childCallbacks = new Dictionary <string, AppendChildData>(); this.BuildChildCallbacks(); }
public override IList <ClientTransaction> FindPending() { List <ClientTransaction> transactions = new List <ClientTransaction>(); StringBuilder builder = new StringBuilder(100); builder.Append("SELECT ctd.ClientTransactionID, ctd.TransactionType, ctd.ObjectData "); builder.Append("FROM ClientTransaction ct "); builder.Append("INNER JOIN ClientTransactionDetail ctd "); builder.Append("ON ct.ClientTransactionID = ctd.ClientTransactionID "); builder.Append("WHERE ct.ReconciliationResult = 1;"); using (DbCommand command = database.GetSqlStringCommand(builder.ToString())) { using (IDataReader reader = database.ExecuteReader(command)) { IEntityFactory <ClientTransaction> entityFactory = EntityFactoryBuilder.BuildFactory <ClientTransaction>(); while (reader.Read()) { transactions.Add(entityFactory.BuildEntity(reader)); } } } return(transactions); }
public void BuildFactoryTest() { IEntityFactory <Project> entityFactory = EntityFactoryBuilder.BuildFactory <Project>(); Assert.AreNotEqual(null, entityFactory); Assert.AreEqual("ProjectFactory", entityFactory.GetType().Name); this.testContextInstance.WriteLine("Created an IEntityFactory<Project> of type {0}", entityFactory.GetType().FullName); }
protected SqlCeRepositoryBase(IUnitOfWork unitOfWork) : base(unitOfWork) { this.database = DatabaseFactory.CreateDatabase(); this.entityFactory = EntityFactoryBuilder.BuildFactory <T>(); this.childCallbacks = new Dictionary <string, AppendChildData>(); this.BuildChildCallbacks(); this.baseQuery = this.GetBaseQuery(); this.baseWhereClause = this.GetBaseWhereClause(); this.entityName = this.GetEntityName(); this.keyFieldName = this.GetKeyFieldName(); }
protected SqlRepositoryBase(IUnitOfWork unitOfWork) : base(unitOfWork) { this._database = DatabaseFactory.CreateDatabase(); this._entityFactory = EntityFactoryBuilder.BuildFactory <T>(); // _childCallBacks é um dicionário que recebe o nome do campo na tabela sql e um método de callback associado // que pode ser usado para preencher outras entidades do agregado. this._childCallbacks = new Dictionary <string, AppendChildData>(); // Caso seja necessário chamar algum callback depois da entidade ser construída. Opcional. this.BuildChildCallbacks(); }
protected SqlCeRepositoryBase(IUnitOfWork unitOfWork) : base(unitOfWork) { DatabaseProviderFactory factory = new DatabaseProviderFactory(); database = factory.Create("SmartCA"); //this.database = DatabaseFactory.CreateDatabase(); this.entityFactory = EntityFactoryBuilder.BuildFactory <T>(); this.childCallbacks = new Dictionary <string, AppendChildData>(); this.BuildChildCallbacks(); this.baseQuery = this.GetBaseQuery(); this.baseWhereClause = this.GetBaseWhereClause(); }
public IList <MarketSegment> FindAllMarketSegments() { List <MarketSegment> segments = new List <MarketSegment>(); string query = "SELECT * FROM MarketSegment mst INNER JOIN MarketSector msr ON mst.MarketSectorID = msr.MarketSectorID;"; IEntityFactory <MarketSegment> factory = EntityFactoryBuilder.BuildFactory <MarketSegment>(); using (IDataReader reader = this.ExecuteReader(query)) { while (reader.Read()) { segments.Add(factory.BuildEntity(reader)); } } return(segments); }
private User GetUserFromSql(string sql) { User user = null; using (DbCommand command = this.database.GetSqlStringCommand(sql)) { using (IDataReader reader = this.database.ExecuteReader(command)) { IEntityFactory <User> entityFactory = EntityFactoryBuilder.BuildFactory <User>(); if (reader.Read()) { user = entityFactory.BuildEntity(reader); } } } return(user); }