Esempio n. 1
0
 public IEnumerable <TEntity> FindAll <TEntity>()
 {
     using (var command = CreateCommand())
     {
         command.CommandText = MetaDataStore.GetTableInfoFor <TEntity>().GetSelectStatementForAllFields().ToString();
         return(Hydrater.HydrateEntities <TEntity>(command));
     }
 }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 3
0
        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));
            }
        }