Ejemplo n.º 1
0
 /// <summary>
 /// Creates a new instance of <see cref="DbQuery{TEntity, TKey}"/>
 /// </summary>
 /// <param name="database">The target <see cref="Database"/> to query to</param>
 /// <param name="sqlDialectProvider">The <see cref="IDbDialectProvider"/> to generate the sql commands</param>
 public DbQuery(Database database, IDbDialectProvider sqlDialectProvider)
 {
     Database   = database;
     Schema     = DbTableSchema.Create(typeof(TEntity));
     Provider   = sqlDialectProvider;
     PrimaryKey = Schema.Columns.Single(i => i.IsPrimaryKey);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new instance of <see cref="TableReference"/>
        /// </summary>
        /// <param name="prop">The <see cref="PropertyInfo"/> to extract the metadata to be used to create the <see cref="TableReference"/> object</param>
        /// <returns>A new instance of <see cref="TableReference"/></returns>
        public static TableReference Create(PropertyInfo prop)
        {
            var entityType = GetReferenceTableEntityType(prop);

            return(new TableReference()
            {
                ReferenceTableKey = prop.GetCustomAttribute <TableReferenceAttribute>().ReferenceTableKey,
                EntityType = entityType,
                IsChild = typeof(IEnumerable).IsAssignableFrom(prop.PropertyType),
                ReferenceTable = DbTableSchema.Create(entityType),
                SourceColumn = DbColumnSchema.Create(prop)
            });
        }
Ejemplo n.º 3
0
 /// <inheritdoc/>
 public IUnitOfWork <TEntity, TKey> Create <TEntity, TKey>()
 {
     return(new DbUnitOfWork <TEntity, TKey>(Database, ProviderFactory.Create(DbTableSchema.Create(typeof(TEntity)))));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates a new instance of <see cref="IDbDialectProvider"/>
 /// </summary>
 /// <param name="entityType">The <see cref="Type"/> for the entity to use for metadata extraction</param>
 /// <returns>A new instance of <see cref="IDbDialectProvider"/></returns>
 public virtual IDbDialectProvider Create(Type entityType)
 {
     return(Create(DbTableSchema.Create(entityType)));
 }