Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tallesl/net-object

Automagically parses (with reflection) an Dictionary/DataRow/DataTable to a custom class of yours.
https://github.com/tallesl/net-object

csharp datarow datatable dictionary dot-net nuget object parse reflection

Last synced: 3 months ago
JSON representation

Automagically parses (with reflection) an Dictionary/DataRow/DataTable to a custom class of yours.

Awesome Lists containing this project

README

        

# Object

[![][build-img]][build]
[![][nuget-img]][nuget]

[build]: https://ci.appveyor.com/project/TallesL/net-object
[build-img]: https://ci.appveyor.com/api/projects/status/github/tallesl/net-object?svg=true
[nuget]: https://www.nuget.org/packages/Object
[nuget-img]: https://badge.fury.io/nu/Object.svg

Automagically parses (with reflection) an DataRow/DataTable/Dictionary to a custom class of yours.

## [DataRow]/[DataTable]

```cs
using ObjectLibrary;

var users = dataTable.ToObject();
```

[DataRow]: https://msdn.microsoft.com/library/System.Data.DataRow
[DataTable]: https://msdn.microsoft.com/library/System.Data.DataTable

## [IDictionary]<string, object>

```cs
using ObjectLibrary;

var userData = new Dictionary { { "Name", "John Smith" }, { "Birth", new DateTime(1970, 1, 1) } };
var userObject = userData.ToObject();
```

[IDictionary]: https://msdn.microsoft.com/library/System.Collections.IDictionary

## [IDictionary]<string, string>

```cs
using ObjectLibrary;

var userData = new Dictionary { { "Name", "John Smith" }, { "Birth", "1970-01-01" } };
var userObject = userData.ToObject();

userData["Birth"] = "Not a date!";
var shitHappens = userData.ToObject(); // throws CouldNotParseException
```