Patch received, many thanks. I'll include it in my next commit. And
yeah, if you want to extend the case (and the tests) to include those
other types, that would be great.
On 29 Oct 2009, at 12:14, Lee Henson wrote:
A patch is winging its way to you right now.
Regarding the other types which aren't currently listed in HqlIdent,
should I be referring to the strings listed in
RegisterDefaultNetTypes() in NHibernate.Type.TypeFactory?
private static void RegisterDefaultNetTypes()
{
// NOTE : each .NET type mut appear only one time
RegisterType(typeof (Byte[]), NHibernateUtil.Binary, new[]
{"binary"},
l => GetType(NHibernateUtil.Binary, l, len => new BinaryType
(SqlTypeFactory.GetBinary(len))));
RegisterType(typeof(Boolean), NHibernateUtil.Boolean, new[]
{ "boolean", "bool" });
RegisterType(typeof (Byte), NHibernateUtil.Byte, new[]{ "byte"});
RegisterType(typeof (Char), NHibernateUtil.Character, new[]
{"character", "char"});
RegisterType(typeof (CultureInfo), NHibernateUtil.CultureInfo, new[]
{ "locale"});
RegisterType(typeof (DateTime), NHibernateUtil.DateTime, new[]
{ "datetime"} );
RegisterType(typeof (DateTimeOffset),
NHibernateUtil.DateTimeOffset, new[]{ "datetimeoffset"});
RegisterType(typeof (Decimal), NHibernateUtil.Decimal, new[]
{"big_decimal", "decimal"},
(p, s) => GetType(NHibernateUtil.Decimal, p, s, st => new
DecimalType(st)));
RegisterType(typeof (Double), NHibernateUtil.Double, new[]
{"double"},
(p, s) => GetType(NHibernateUtil.Double, p, s, st => new
DoubleType(st)));
RegisterType(typeof (Guid), NHibernateUtil.Guid, new[]{ "guid"});
RegisterType(typeof (Int16), NHibernateUtil.Int16, new[]{ "short"});
RegisterType(typeof (Int32), NHibernateUtil.Int32, new[]
{"integer", "int"});
RegisterType(typeof (Int64), NHibernateUtil.Int64, new[]{ "long"});
RegisterType(typeof(SByte), NHibernateUtil.SByte, EmptyAliases);
RegisterType(typeof (Single), NHibernateUtil.Single, new[]
{"float", "single"},
(p, s) => GetType(NHibernateUtil.Single, p, s, st => new
SingleType(st)));
RegisterType(typeof (String), NHibernateUtil.String, new[]
{"string"},
l => GetType(NHibernateUtil.String, l, len => new StringType
(SqlTypeFactory.GetString(len))));
RegisterType(typeof (TimeSpan), NHibernateUtil.TimeSpan, new[]
{"timespan"});
RegisterType(typeof (System.Type), NHibernateUtil.Class, new[]
{"class"},
l => GetType(NHibernateUtil.Class, l, len => new TypeType
(SqlTypeFactory.GetString(len))));
RegisterType(typeof (UInt16), NHibernateUtil.UInt16, new[]
{"ushort"});
RegisterType(typeof (UInt32), NHibernateUtil.UInt32, new[] {"uint"});
RegisterType(typeof (UInt64), NHibernateUtil.UInt64, new[]
{"ulong"});
// object needs to have both class and serializable setup before it
can
// be created.
RegisterType(typeof (Object), NHibernateUtil.Object, new[]
{"object"});
}
2009/10/29 Steve Strong <[email protected]>
Hi Lee,
Your fix is perfect - add a test to LinqQuerySamples and make the
change and send me the patch. Feel free to do it for any other types
whilst you're at it :)
Cheers,
Steve
On 28 Oct 2009, at 19:50, Lee Henson wrote:
Hi
I'm attempting to run a very simple query using the new linq provider:
from w in session.Query<Widget>()
where w.Key == Guid.Empty
select w
It is throwing an exception in the default clause of this switch
statement in the constructor of HqlIdent, as the typecode of type is
Object:
switch (System.Type.GetTypeCode(type))
{
case TypeCode.Boolean:
_node.Text = "bool";
break;
case TypeCode.Int32:
_node.Text = "integer";
break;
case TypeCode.Decimal:
_node.Text = "decimal";
break;
case TypeCode.DateTime:
_node.Text = "datetime";
break;
case TypeCode.String:
_node.Text = "string";
break;
default:
throw new NotSupportedException(string.Format("Don't
currently
support idents of type {0}", type.Name));
}
I appreciate Steve is doing a super-human job of cranking this
provider out, but I was wondering if (with a little guidance) I might
be able to add support for this scenario myself?
In that regard, what are the implications of adding this clause?:
case TypeCode.Object:
_node.Text = "guid";
break;
It seems to allow my query to work as expected, and does not cause any
other tests to fail.
Cheers
Lee