/// <summary> /// Chooses the appropriate DbType for the given string type. /// </summary> private static DbType GetStringDbType(TypeUsage type) { Debug.Assert(type.EdmType.BuiltInTypeKind == BuiltInTypeKind.PrimitiveType && PrimitiveTypeKind.String == ((PrimitiveType)type.EdmType).PrimitiveTypeKind, "only valid for string type"); DbType dbType; // Specific type depends on whether the string is a unicode string and whether it is a fixed length string. // By default, assume widest type (unicode) and most common type (variable length) bool unicode; bool fixedLength; if (!type.TryGetIsFixedLength(out fixedLength)) { fixedLength = false; } unicode = type.GetIsUnicode(); if (fixedLength) { dbType = (unicode ? DbType.StringFixedLength : DbType.AnsiStringFixedLength); } else { dbType = (unicode ? DbType.String : DbType.AnsiString); } return(dbType); }
private static VfpType GetBinaryVfpType(TypeUsage type) { Debug.Assert(type.EdmType.BuiltInTypeKind == BuiltInTypeKind.PrimitiveType && PrimitiveTypeKind.Binary == ((PrimitiveType)type.EdmType).PrimitiveTypeKind, "only valid for binary type"); bool fixedLength; if (!type.TryGetIsFixedLength(out fixedLength)) { fixedLength = false; } return(fixedLength ? VfpType.Blob : VfpType.Varbinary); }
/// <summary> /// Chooses the appropriate DbType for the given binary type. /// </summary> private static DbType GetBinaryDbType(TypeUsage type) { Debug.Assert(type.EdmType.BuiltInTypeKind == BuiltInTypeKind.PrimitiveType && PrimitiveTypeKind.Binary == ((PrimitiveType)type.EdmType).PrimitiveTypeKind, "only valid for binary type"); // Specific type depends on whether the binary value is fixed length. By default, assume variable length. bool fixedLength; if (!type.TryGetIsFixedLength(out fixedLength)) { // ReSharper disable once RedundantAssignment fixedLength = false; } return(DbType.Binary); // return fixedLength ? DbType.Binary : DbType.VarBinary; }
/// <summary> /// Chooses the appropriate OleDbType for the given binary type. /// </summary> private static OleDbType GetBinaryDbType(TypeUsage type) { if (type.EdmType.BuiltInTypeKind != BuiltInTypeKind.PrimitiveType || PrimitiveTypeKind.Binary != ((PrimitiveType)type.EdmType).PrimitiveTypeKind) { throw new ArgumentException("GetBinaryDbType require a TypeUsage of binary type", "tu"); } // Specific type depends on whether the binary value is fixed length. By default, assume variable length. bool fixedLength; if (!type.TryGetIsFixedLength(out fixedLength)) { fixedLength = false; } return(fixedLength ? OleDbType.Binary : OleDbType.VarBinary); }
private static VfpType GetStringVfpType(TypeUsage type, int?size) { Debug.Assert(type.EdmType.BuiltInTypeKind == BuiltInTypeKind.PrimitiveType && PrimitiveTypeKind.String == ((PrimitiveType)type.EdmType).PrimitiveTypeKind, "only valid for string type"); if (type.EdmType.Name.ToLowerInvariant() == "xml") { return(VfpType.Memo); } bool fixedLength; if (!type.TryGetIsFixedLength(out fixedLength)) { fixedLength = false; } return(VfpMapping.GetVfpStringType(size ?? 0, fixedLength)); }
/// <summary> /// Chooses the appropriate OleDbType for the given string type. /// </summary> private static OleDbType GetStringDbType(TypeUsage tu) { if (tu.EdmType.BuiltInTypeKind != BuiltInTypeKind.PrimitiveType || PrimitiveTypeKind.String != ((PrimitiveType)tu.EdmType).PrimitiveTypeKind) { throw new ArgumentException("GetStringDbType require a TypeUsage of string type", "tu"); } OleDbType dbType; if (tu.EdmType.Name.ToLowerInvariant() == "xml") { // JET: dbType = OleDbType.Xml; dbType = OleDbType.LongVarChar; } else { // Specific type depends on whether the string is a unicode string and whether it is a fixed length string. // By default, assume widest type (unicode) and most common type (variable length) bool unicode; bool fixedLength; if (!tu.TryGetIsFixedLength(out fixedLength)) { fixedLength = false; } unicode = tu.GetIsUnicode(); // This should change return type to NVarChar/NChar but in Jet everything is in unicode if (fixedLength) { dbType = OleDbType.Char; } else { dbType = OleDbType.VarChar; } } return(dbType); }