-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
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
Use ClassMap to create constructor parameter mapping #955
Comments
Would it be worthwhile to look at how EF Core does it? https://docs.microsoft.com/en-us/ef/core/modeling/constructors |
I like that convention.
|
any update on this, really would be a handy feature? |
It's still planned. There are a few things that have higher priority though and I don't have a lot of time at the moment. |
I'm having massive issues with this at the moment. It may warrant a separate support ticket. I have raised a separate ticket #1482 |
This was done as part of another feature several months ago. |
Which feature? How is it used? |
You use void Main()
{
var s = new StringBuilder();
s.Append("Id,Name\r\n");
s.Append("1,one\r\n");
var config = new CsvConfiguration(CultureInfo.InvariantCulture)
{
};
using (var reader = new StringReader(s.ToString()))
using (var csv = new CsvReader(reader, config))
{
csv.Context.RegisterClassMap<FooMap>();
csv.GetRecords<Foo>().ToList().Dump();
}
}
private class Foo
{
public int Id { get; private set; }
public string Name { get; private set; }
public Foo(int theId, string theName)
{
Id = theId;
Name = theName;
}
}
private class FooMap : ClassMap<Foo>
{
public FooMap()
{
Parameter("theId").Name("Id");
Parameter("theName").Name("Name");
}
} |
Look into what sort of work is required to do this.
Maybe everything can stay the same and there is a map type or something that can be changed.
#1484
The text was updated successfully, but these errors were encountered: