I implemented GenericWellKnownInstanceType from the unoficial
NHibernate addins and managed to get my custom user type persisted
without any issues. What I'm struggling with is retrieving all data
from my new type.
The query I'm using is as simple as it gets. It returns no errors and
no data.
var states = Session.QueryOver<State>().List();
How can I retrieve all states in the system?
I've looked at the addins tests and none of them test this scenario so
maybe this isn't possible?
Here is the rest of my code:
[Serializable]
public class State
{
public State(int id, string name)
{
Id = id;
Name = name;
}
public int Id { get; set; }
public string Name { get; set; }
}
public class States : ReadOnlyCollection<State>
{
public static State FirstState = new State(0, "First State");
public static State SecondState = new State(1, "Second State");
public States()
: base(new [] { FirstState, SecondState })
{
}
}
public class StateUserType : GenericWellKnownInstanceType<State, int>
{
public StateUserType()
: base(new States(),
(entity, id) => entity.Id == id,
entity => entity.Id)
{
}
public override SqlType[] SqlTypes
{
get { return new[] { SqlTypeFactory.Int16 }; }
}
}
* Note that this is a cross post with SO.
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.