Skip to content

Functionality to add values not in the model #10

@mikecasas

Description

@mikecasas

Do you see any need to add functionality that would add a value to the table that is outside of the model properties? The example below would add the value 'student' to the category column in the People table.

var mapper = new MapperBuilder<Person>()
    .SetTableName("People") // could be ommited if your table's name is the same as you entity's class name
    .AddMapping(person => person.FirstName, columnName: "Name")
    .AddMapping(person => person.LastName, columnName: "Surename")
    .AddMapping(person => person.DateOfBirth) // in this case property's name is the same as table column's name

   .AddConstant("student", columnName: "Category")

    .Build();

//Don't want to alter the person model!!!!

var people = new List<Person>()
{ 
    new Person() { FirstName = "John", LastName = "Lennon", DateOfBirth = new DateTime(1940, 10, 9) },
    new Person() { FirstName = "Paul", LastName = "McCartney", DateOfBirth = new DateTime(1942, 6, 18) },
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions