We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I tried to create a generalized function to create a csv file from every class omitting the object field (only string, number, boolean date etc etc)
when i run it i get the following error
Line 157: The type or namespace name 'it' could not be found (are you missing a using directive or an assembly reference?)
and in the Stacktrace is
in FileHelpers.Dynamic.ClassBuilder.ClassFromString(String classStr, String className, NetLanguage lang, List`1 additionalReferences) in FileHelpers.Dynamic.ClassBuilder.CreateRecordClass()
in FileHelpers.Dynamic.ClassBuilder.ClassFromString(String classStr, String className, NetLanguage lang, List`1 additionalReferences)
in FileHelpers.Dynamic.ClassBuilder.CreateRecordClass()
The namespace of my application is something like it.mycompany.client.project.main.lib.Model.ModelEdmx for autogenerated class
it.mycompany.client.project.main.web.Management.AsyncTask for the class where the function is.
The class has using it.mycompany.client.project.main.lib.Model.ModelEdmx
Method:
private static string CreateFileGeneric<T>(IEnumerable<T> records, string name, PerformContext context) { context.Info($"Create file for {name}"); var basePath = System.AppDomain.CurrentDomain.BaseDirectory + AppConfig.TASK_ARCHIVE_LOCAL_FOLDER; var HeaderLine = String.Join(";", typeof(T).GetFields().Select(f => $"\"{f.Name}\"").ToList()); string filename = name.Replace(" ", "_").Replace(".", "_") + "_" + DateTime.Now.ToString("yyyyMMddTHHmmss") + ".csv"; string path = Path.Combine(basePath, filename); var cb = new DelimitedClassBuilder(typeof(T).Name, ";") { IgnoreEmptyLines = true }; foreach (var prop in typeof(T).GetProperties()) { if (!(prop.PropertyType.IsClass && prop.PropertyType != typeof(string))) { var fieldBuilder = cb.AddField(prop.Name, prop.PropertyType); if (fieldBuilder.FieldType == "System.String") { cb.LastField.TrimMode = TrimMode.Both; cb.LastField.QuoteMode = QuoteMode.AlwaysQuoted; cb.LastField.QuoteChar = '"'; } if (fieldBuilder.FieldType == "System.DateTime") { cb.LastField.Converter.Arg1 = "dd/MM/yyyy HH:mm:ss:fff"; } } } var recordClass = cb.CreateRecordClass(); var fileHelper = new FileHelperEngine(recordClass); fileHelper.HeaderText = HeaderLine; fileHelper.WriteFile(path, (IEnumerable<object>)records); return filename; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I tried to create a generalized function to create a csv file from every class omitting the object field (only string, number, boolean date etc etc)
when i run it i get the following error
and in the Stacktrace is
The namespace of my application is something like
it.mycompany.client.project.main.lib.Model.ModelEdmx for autogenerated class
it.mycompany.client.project.main.web.Management.AsyncTask for the class where the function is.
The class has using it.mycompany.client.project.main.lib.Model.ModelEdmx
Method:
The text was updated successfully, but these errors were encountered: