public void TestDictionaryToObjectWithOneAsBoolean() { var dict = new Dictionary <string, object?> { { "Id", 1 }, { "Name", "name" }, { "Number", null }, { "Check", 1 }, { "DateTime", TestDateTime } }; var obj = ComponentModelHelper.ToObject <TestObject>(dict); obj.Check.Should().BeTrue(); }
public void TestDictionaryToObjectWithDbNull() { var dict = new Dictionary <string, object?> { { "Id", 1 }, { "Name", "name" }, { "Number", null }, { "check", false }, { "DateTime", DBNull.Value } }; var obj = ComponentModelHelper.ToObject <TestObject>(dict); obj.DateTime.Should().BeNull(); }
public void TestDictionaryToObject() { var dict = new Dictionary <string, object?> { { "Id", 1 }, { "Name", "name" }, { "Number", null }, { "Check", false }, { "DateTime", TestDateTime } }; var obj = ComponentModelHelper.ToObject <TestObject>(dict); obj.Id.Should().Be(1); obj.Name.Should().Be("name"); obj.Number.Should().BeNull(); obj.Check.Should().BeFalse(); obj.DateTime.Should().Be(TestDateTime); }
public void TestSnakeCasedDictionaryToObject() { var dict = new Dictionary <string, object?> { { "id", 1 }, { "name", "name" }, { "number", null }, { "check", false }, { "date_time", TestDateTimeString } }; var obj = ComponentModelHelper.ToObject <TestObject>(dict, new CamelToSnakeColumnFormat()); obj.Id.Should().Be(1); obj.Name.Should().Be("name"); obj.Number.Should().BeNull(); obj.Check.Should().BeFalse(); obj.DateTime.Should().Be(TestDateTime); }
public async Task <IReadOnlyList <T> > ListAsync <T>() where T : new() { return((await ResultsAsync()).MapReadOnly(d => ComponentModelHelper.ToObject <T>(d, _options.ColumnFormat))); }
public IReadOnlyList <T> List <T>() where T : new() { return(Results().MapReadOnly(d => ComponentModelHelper.ToObject <T>(d, _options.ColumnFormat))); }