I have two properties in a class that are using CompositeUserType and
i am trying to use Conditional Projection
on these two properties and i am recieving the exception "Bothtrue
andfalseprojectionsmustreturnthesametypesButTrueprojection
returns: [NHibernate.Type.CompositeCustomType]
AndFalseprojection returns: [NHibernate.Type.CompositeCustomType]".
If i won't use CompositeUserType for those properties it works fine.
I am using the following EmptyStringUserType
[Serializable]
public class EmptyStringUserType : ICompositeUserType
{
public EmptyStringUserType()
{
}
public System.Type ReturnedClass
{
get
{
returntypeof(string);
}
}
public bool IsMutable
{
get {returntrue; }
}
public String[] PropertyNames
{
get
{
returnnew String[] { "string" };
}
}
public NHibernate.Type.IType[] PropertyTypes
{
get
{
returnnew NHibernate.Type.IType[]
{ NHibernateUtil.String };
}
}
public object Assemble(object cached,
NHibernate.Engine.ISessionImplementor session, object owner)
{
returnDeepCopy(cached);
}
public object Disassemble(Object value,
NHibernate.Engine.ISessionImplementor session)
{
returnDeepCopy(value);
}
public Object DeepCopy(Object a)
{
if (a == null)returnnull;
returna;
}
public new bool Equals(object x, object y)
{
return(x == y) || (x != null && y != null && (x.Equals
(y)));
}
public object NullSafeGet(System.Data.IDataReader rs, String[]
names, NHibernate.Engine.ISessionImplementor session, Object owner)
{
returnNHibernateUtil.String.NullSafeGet(rs, names[0],
session, owner);
}
public void NullSafeSet(System.Data.IDbCommand st, Object
value, int index, NHibernate.Engine.ISessionImplementor session)
{
string str = null;
if (value != null) str = value.ToString().Trim();
if (str == String.Empty)
{
str = null;
NHibernateUtil.String.NullSafeSet(st, str, index,
session);
}
else
NHibernateUtil.String.NullSafeSet(st, value, index,
session);
}
public Object GetPropertyValue(Object component, int property)
{
returnnull;
}
public void SetPropertyValue(Object object1, int i, Object
object2)
{
}
#region ICompositeUserType Members
public int GetHashCode(object x)
{
returnx == null ? typeof(string).GetHashCode() :
x.GetHashCode();
}
public object Replace(object original, object target,
ISessionImplementor session, object owner)
{
returnDeepCopy(original);
}
public override string ToString()
{
return"test";
}
#endregion
}
Thanks,
Sravan
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---