public IEnumerable <TEntity> FindAll <TEntity>() { using (var command = CreateCommand()) { command.CommandText = MetaDataStore.GetTableInfoFor <TEntity>().GetSelectStatementForAllFields().ToString(); return(Hydrater.HydrateEntities <TEntity>(command)); } }
public void InitializeProxy(object proxy, Type targetType) { using (var command = CreateCommand()) { var tableInfo = MetaDataStore.GetTableInfoFor(targetType); var query = tableInfo.GetSelectStatementForAllFields(); tableInfo.AddWhereByIdClause(query); object id = tableInfo.PrimaryKey.PropertyInfo.GetValue(proxy, null); command.CommandText = query.ToString(); command.CreateAndAddInputParameter(tableInfo.PrimaryKey.DbType, tableInfo.GetPrimaryKeyParameterName(), id); Hydrater.UpdateEntity(targetType, proxy, command); } }
public TEntity Get <TEntity>(object id) { var cachedEntity = SessionLevelCache.TryToFind(typeof(TEntity), id); if (cachedEntity != null) { return((TEntity)cachedEntity); } using (var command = CreateCommand()) { var tableInfo = MetaDataStore.GetTableInfoFor <TEntity>(); var query = tableInfo.GetSelectStatementForAllFields(); tableInfo.AddWhereByIdClause(query); command.CommandText = query.ToString(); command.CreateAndAddInputParameter(tableInfo.PrimaryKey.DbType, tableInfo.GetPrimaryKeyParameterName(), id); return(Hydrater.HydrateEntity <TEntity>(command)); } }