public static void Export(ExportArguments exportArgs) { var connStrBuilder = new MySqlConnectionStringBuilder { Server = exportArgs.Server, UserID = exportArgs.User, Password = exportArgs.Password, Database = exportArgs.Database }; var model = new DynamicModel(connStrBuilder.ConnectionString, exportArgs.Table); IEnumerable<dynamic> records = exportArgs.UseQuery ? model.Query(exportArgs.Query) : model.All(); string json = JsonConvert.SerializeObject(records); Console.WriteLine(json); }
public static ExportArguments Parse(string[] args) { var exportArgs = new ExportArguments(); var optionsSet = new OptionSet { { "s=|server=", s => exportArgs.Server = s }, { "u=|user="******"p=|password="******"t=|table=", t => exportArgs.Table = t }, { "d=|database=", d => exportArgs.Database = d }, { "e=|execute=", e => exportArgs.Query = e} }; optionsSet.Parse(args); return exportArgs; }