Esempio n. 1
0
        /// <summary>Column list.</summary>
        /// <typeparam name="T">Generic type parameter.</typeparam>
        /// <param name="withTablePrefix">true to with table prefix.</param>
        /// <returns>A List&lt;string&gt;</returns>
        private List <string> ColumnList <T>(bool withTablePrefix = true)
        {
            var           pocoType  = typeof(T);
            var           tableName = pocoType.GetModelDefinition().ModelName;
            List <string> result    = new List <string>(pocoType.GetModelDefinition().FieldDefinitions.Count);

            foreach (var item in pocoType.GetModelDefinition().FieldDefinitions)
            {
                var name = _dialectProvider.GetQuotedColumnName(item.FieldName);

                if (item.Name != item.FieldName)
                {
                    name += " AS " + _dialectProvider.GetQuotedColumnName(item.Name);
                }

                if (withTablePrefix)
                {
                    result.Add(string.Format("{0}.{1}", _dialectProvider.GetQuotedTableName(tableName), name));
                }
                else
                {
                    result.Add(name);
                }
            }
            return(result);
        }
        internal TypedWhereStatement(IDialectProvider dialectProvider)
        {
            _dialectProvider = dialectProvider;
            _modelDefinition = ModelDefinition <T> .Definition;

            WhereStatement.TableName = _dialectProvider.GetQuotedTableName(_modelDefinition);
        }
        public TypedSelectStatement(IDialectProvider dialectProvider)
            : base(dialectProvider)
        {
            _dialectProvider = dialectProvider;
            _modelDefinition = ModelDefinition <T> .Definition;

            Statement.TableName = _dialectProvider.GetQuotedTableName(_modelDefinition);
            Statement.Columns.AddRange(_dialectProvider.GetColumnNames(_modelDefinition));
        }
Esempio n. 4
0
 public DynamicCountStatement From(string tableName, string schemaName = null)
 {
     Statement.TableName = _dialectProvider.GetQuotedTableName(tableName, schemaName);
     return(this);
 }
 /// <summary>
 ///     Used to overwrite the tablename generated from the Typed parameter
 /// </summary>
 /// <param name="tableName">The new table name</param>
 /// <returns></returns>
 public virtual TypedWhereStatement <T> From(string tableName)
 {
     WhereStatement.TableName = _dialectProvider.GetQuotedTableName(tableName);
     return(this);
 }
Esempio n. 6
0
 /// <summary>
 ///     Override name of the table to insert values into.
 /// </summary>
 /// <param name="tableName"></param>
 /// <returns></returns>
 public TypedUpdateStatement <T> Table(string tableName, string schemaName = null)
 {
     Statement.TableName = _dialectProvider.GetQuotedTableName(tableName, schemaName);
     return(this);
 }
Esempio n. 7
0
 public TypedUpdateStatement(IDialectProvider dialectProvider)
     : base(dialectProvider)
 {
     _dialectProvider    = dialectProvider;
     Statement.TableName = _dialectProvider.GetQuotedTableName(_modelDefinition);
 }
Esempio n. 8
0
 /// <summary>
 ///     Override name of the table to insert values into.
 /// </summary>
 /// <param name="tableName"></param>
 /// <returns></returns>
 public TypedInsertStatement <T> Into(string tableName, string schema = null)
 {
     Statement.TableName = _dialectProvider.GetQuotedTableName(tableName, schema);
     return(this);
 }
Esempio n. 9
0
 public TypedInsertStatement(IDialectProvider dialectProvider)
 {
     _dialectProvider      = dialectProvider;
     Statement.TableName   = _dialectProvider.GetQuotedTableName(_modelDefinition);
     Statement.HasIdentity = _modelDefinition.FieldDefinitions.Any(x => x.AutoIncrement);
 }