当前位置: 首页>>代码示例>>C#>>正文


C# ProviderType.IsSameTypeFamily方法代码示例

本文整理汇总了C#中ProviderType.IsSameTypeFamily方法的典型用法代码示例。如果您正苦于以下问题:C# ProviderType.IsSameTypeFamily方法的具体用法?C# ProviderType.IsSameTypeFamily怎么用?C# ProviderType.IsSameTypeFamily使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProviderType的用法示例。


在下文中一共展示了ProviderType.IsSameTypeFamily方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BothTypesAreStrings

		private bool BothTypesAreStrings(ProviderType oldSqlType, ProviderType newSqlType)
		{
			bool result = oldSqlType.IsSameTypeFamily(sql.TypeProvider.From(typeof(string)))
				&& newSqlType.IsSameTypeFamily(sql.TypeProvider.From(typeof(string)));

			return result;
		}
开发者ID:modulexcite,项目名称:LinqToSQL2,代码行数:7,代码来源:SqlTypeConverter.cs

示例2: ChangeTypeFamilyTo

		internal override ProviderType ChangeTypeFamilyTo(ProviderType type, ProviderType toType)
		{
			// if this is already the same family, do nothing
			if(type.IsSameTypeFamily(toType))
				return type;

			// otherwise as a default return toType
			// but look for special cases we have to convert carefully
			if(type.IsApplicationType || toType.IsApplicationType)
				return toType;
			SqlType sqlToType = (SqlType)toType;
			SqlType sqlThisType = (SqlType)type;

			if(sqlToType.Category == TypeCategory.Numeric && sqlThisType.Category == TypeCategory.Char)
			{
				switch(sqlThisType.SqlDbType)
				{
					case SqlDbType.NChar:
						return SqlTypeSystem.Create(SqlDbType.Int);
					case SqlDbType.Char:
						return SqlTypeSystem.Create(SqlDbType.SmallInt);
					default:
						return toType;
				}
			}
			else
			{
				return toType;
			}
		}
开发者ID:modulexcite,项目名称:LinqToSQL2,代码行数:30,代码来源:SqlServerProviderBase.cs

示例3: PredictTypeForBinary

		internal override ProviderType PredictTypeForBinary(SqlNodeType binaryOp, ProviderType leftType, ProviderType rightType)
		{
			SqlType highest;

			if(leftType.IsSameTypeFamily(this.From(typeof(string))) && rightType.IsSameTypeFamily(this.From(typeof(string))))
			{
				highest = (SqlType)this.GetBestType(leftType, rightType);
			}
			else
			{
				int coercionPrecedence = leftType.ComparePrecedenceTo(rightType);
				highest = (SqlType)(coercionPrecedence > 0 ? leftType : rightType);
			}

			switch(binaryOp)
			{
				case SqlNodeType.Add:
				case SqlNodeType.Sub:
				case SqlNodeType.Mul:
				case SqlNodeType.Div:
				case SqlNodeType.BitAnd:
				case SqlNodeType.BitOr:
				case SqlNodeType.BitXor:
				case SqlNodeType.Mod:
				case SqlNodeType.Coalesce:
					return highest;
				case SqlNodeType.Concat:
					// When concatenating two types with size, the result type after
					// concatenation must have a size equal to the sum of the two sizes.
					if(highest.HasSizeOrIsLarge)
					{
						// get the best type, specifying null for size so we get
						// the maximum allowable size
						ProviderType concatType = this.GetBestType(highest.SqlDbType, null);

						if((!leftType.IsLargeType && leftType.Size.HasValue) &&
						   (!rightType.IsLargeType && rightType.Size.HasValue))
						{
							// If both types are not large types and have size, and the
							// size is less than the default size, return the shortened type.
							int concatSize = leftType.Size.Value + rightType.Size.Value;
							if((concatSize < concatType.Size) || concatType.IsLargeType)
							{
								return GetBestType(highest.SqlDbType, concatSize);
							}
						}

						return concatType;
					}
					return highest;
				case SqlNodeType.And:
				case SqlNodeType.Or:
				case SqlNodeType.LT:
				case SqlNodeType.LE:
				case SqlNodeType.GT:
				case SqlNodeType.GE:
				case SqlNodeType.EQ:
				case SqlNodeType.NE:
				case SqlNodeType.EQ2V:
				case SqlNodeType.NE2V:
					return ProviderConstants.IntType;
				default:
					throw Error.UnexpectedNode(binaryOp);
			}
		}
开发者ID:modulexcite,项目名称:LinqToSQL2,代码行数:65,代码来源:SqlServerProviderBase.cs


注:本文中的ProviderType.IsSameTypeFamily方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。