Source/Providers/NFX.MySQL/MySQLCRUDScriptQueryHandler.cs
/// <summary>
/// Gets CRUD schema from MySqlReader per particular QuerySource.
/// If source is null then all columns from reader are copied.
/// Note: this code was purposely made provider specific because other providers may treat some nuances differently
/// </summary>
Gets CRUD schema from MySqlReader per particular QuerySource.
If source is null then all columns from reader are copied.
Note: this code was purposely made provider specific because other providers may treat some nuances differently
Gets CRUD schema from MySqlReader per particular QuerySource . If source is null then all columns from reader are copied . Note : this code was purposely made provider specific because other providers may treat some nuances differently
public static Schema GetSchemaFromReader(string name, QuerySource source, MySqlDataReader reader)
            {
               var table = name;
               var fdefs = new List<Schema.FieldDef>();
               for (int i = 0; i < reader.FieldCount; i++)
               {
                    var fname = reader.GetName(i);
                    var ftype = reader.GetFieldType(i);
                    var def = new Schema.FieldDef(fname, ftype, source!=null ? ( source.HasPragma ? source.ColumnDefs[fname] : null) : null);
                    fdefs.Add( def );
               }
               if (source!=null)
                if (source.HasPragma && source.ModifyTarget.IsNotNullOrWhiteSpace()) table = source.ModifyTarget;
               if (table.IsNullOrWhiteSpace()) table = Guid.NewGuid().ToString();
               return new Schema(table, source!=null ? source.ReadOnly : true,  fdefs);
            }
public static Schema GetSchemaFromReader ( string name , QuerySource source , MySqlDataReader reader ) { var table = name ; var fdefs = new List < Schema . FieldDef > ( ) ; for ( int i = 0 ; i < reader . FieldCount ; i ++ ) { var fname = reader . GetName ( i ) ; var ftype = reader . GetFieldType ( i ) ; var def = new Schema . FieldDef ( fname , ftype , source != null ? ( source . HasPragma ? source . ColumnDefs [ fname ] : null ) : null ) ; fdefs . Add ( def ) ; } if ( source != null ) if ( source . HasPragma && source . ModifyTarget . IsNotNullOrWhiteSpace ( ) ) table = source . ModifyTarget ; if ( table . IsNullOrWhiteSpace ( ) ) table = Guid . NewGuid ( ) . ToString ( ) ; return new Schema ( table , source != null ? source . ReadOnly : true , fdefs ) ; }
Gets CRUD schema from MySqlReader per particular QuerySource.
Gets CRUD schema from MySqlReader per particular QuerySource .
name
string
source
QuerySource
reader
MySqlDataReader