Пример #1
0
        public override IReadOnlyList <DbGeneratedColumn> GetDbGeneratedColumns()
        {
            SchemaContext schemaContext = base.SchemaContextPool.Rent();

            try
            {
                var dbGeneratedColumns = new List <DbGeneratedColumn>();
                var dbSet = new InternalDbSet <MySqlModelCustomizer.MySqlDbGeneratedColumn>(schemaContext);
                foreach (MySqlModelCustomizer.MySqlDbGeneratedColumn column in
                         dbSet.FromSqlRaw("SELECT TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, EXTRA FROM INFORMATION_SCHEMA.COLUMNS WHERE EXTRA <> ''"))
                {
                    var dbGeneratedColumn = new DbGeneratedColumn()
                    {
                        ColumnName  = column.ColumnName,
                        TableName   = column.TableName,
                        TableSchema = column.TableSchema
                    };

                    if (column.Extra == "auto_increment")
                    {
                        dbGeneratedColumn.IsIdentity = true;
                    }
                    else
                    {
                        dbGeneratedColumn.IsComputed = true;
                    }

                    dbGeneratedColumns.Add(dbGeneratedColumn);
                }
                return(dbGeneratedColumns);
            }
            finally
            {
                base.SchemaContextPool.Return(schemaContext);
            }
        }
Пример #2
0
            public IQueryable FromSql(Object dataContext, String sql, Object?[] parameters)
            {
                var dbSet = new InternalDbSet <TEntity>((T)dataContext);

                return(dbSet.FromSqlRaw(sql, parameters));
            }