Skip to content

C# utility for conversion between tabular data and anonymous typed / compatible class objects

Notifications You must be signed in to change notification settings

immaxchen/DataMappingUtility

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DataMappingUtility

C# utility for conversion between tabular data and anonymous typed / compatible class objects

Target .NET Framework 3.5+

Need to reference EPPlus for Excel I/O

Example

create anonymous typed objects on the fly

using DataMappingUtility;

var table = DataIO.ReadExcel("users.xlsx");
var users = table.Generate(new
    {
        UserId = default(int?),
        Name = default(string),
        Gender = default(string),
        Birthday = default(DateTime?),
    });

var boys = users.Where(x => x.Gender == "Male");

or using a compatible class definition

var users = table.Generate(new User());

a simple helper class is provided to validate the data

var validator = new TableValidator(table);
validator.Field("UserId").IsRequired();
validator.Field("UserId").IsUnique();
validator.Field("Name").IsRequired();
validator.Field("Gender").IsIn("Male", "Female");
validator.Field("Birthday").IsDateTime();
var log = validator.Validate();

About

C# utility for conversion between tabular data and anonymous typed / compatible class objects

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages