1
votes

I have an entity which is constructed from a string and can be serialized to a string, e.g.

public class EntityPart { 
    public EntityPart(string str) {
        // some construction logic
    } 
    public override string ToString() {
        // some serialization logic
    } 
}

and a domain object that contains a property of this type, e.g.

public class Entity {
    public virtual EntityPart Part { get; set; }
}

I would like to map this property to an nvarchar(x) column of my table. Which is the best way to perform this mapping with Fluent NHibernate (or in pure NHibernate) and preserve the ability to perform queries by this column with NHibernate.Linq? (The queries won't include anything more complicated than "==" and "!=" comparisons.)

1

1 Answers

1
votes

Store it as a Component on the Entity table. See ComponentMap<> at:

http://wiki.fluentnhibernate.org/Fluent_mapping