Mike
unread,Feb 10, 2012, 11:32:12 AM2/10/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to nhusers
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.