Search code examples
linq-to-sqlvalidationmappings

validate linqtosql mapping to a model


I have generated a LinqtoSQL mapping xml file, which I have a valid XSD schema that I check to make sure the XML is correct.

Now I want to check that the field type match the Model/Interface

for example:

checking that the nullable fields are nullable that int are int etc

anyone got any ideas if I can do this?


Solution

  • One way I have found is to just pass in a new object without setting anything:

    [Test]
    [Rollback]
    public void Should_take_a_Document_with_nulls()
    {
    // Arrange
    var repository = GetRepository();
    var contact = new Contact();
    
    // Act
    repository.Save(contact);
    
    // Assert
    }