/// <summary>
		/// Guesses the IType by the type
		/// </summary>
		/// <param name="type">The type.</param>
		/// <returns></returns>
		public static IType GuessType(System.Type type)
		{
			type = type.UnwrapIfNullable();

			IType value;
			if (clrTypeToNHibernateType.TryGetValue(type, out value))
				return value;
			
			if (type.IsEnum)
				return (IType) Activator.CreateInstance(typeof (EnumType<>).MakeGenericType(type));
			
			if (typeof(IUserType).IsAssignableFrom(type) ||
				typeof(ICompositeUserType).IsAssignableFrom(type))
			{
				return Custom(type);
			}
			
			return Entity(type);
		}
예제 #2
0
		internal HqlIdent(IASTFactory factory, System.Type type)
			: base(HqlSqlWalker.IDENT, "", factory)
		{
			type = type.UnwrapIfNullable();

			switch (System.Type.GetTypeCode(type))
			{
				case TypeCode.Boolean:
					SetText("bool");
					break;
				case TypeCode.Int16:
					SetText("short");
					break;
				case TypeCode.Int32:
					SetText("integer");
					break;
				case TypeCode.Int64:
					SetText("long");
					break;
				case TypeCode.Decimal:
					SetText("decimal");
					break;
				case TypeCode.Single:
					SetText("single");
					break;
				case TypeCode.DateTime:
					SetText("datetime");
					break;
				case TypeCode.String:
					SetText("string");
					break;
				case TypeCode.Double:
					SetText("double");
					break;
				default:
					if (type == typeof(Guid))
					{
						SetText("guid");
						break;
					}
					if (type == typeof(DateTimeOffset))
					{
					    SetText("datetimeoffset");
					    break;
					}
					throw new NotSupportedException(string.Format("Don't currently support idents of type {0}", type.Name));
			}
		}