How to map non-primitive members to bytes/JSON with NPoco?

524 Views Asked by At

Say I have an object:

class Person {
    public int Id {get; set;}
    public string Name {get; set;}
    public Address HomeAddress {get; set;};
}
class Address {
    public string Street {get; set;}
    public string City {get; set;}
}

I want/need the above object to be mapped to a single column named Person which has a column named HomeAddress whose content is a JSON (or some custom binary serialization).

How do I tell NPoco Database object to use such mapping?

1

There are 1 best solutions below

0
On

You would use the [SerializedColumn] attribute on the HomeAddress property of the Person class. This will serialize/deserialize json text that is stored in the column.