public override string EscapeLikeArgument(string argument) { Check.NotNull <string>(argument, nameof(argument)); bool usedEscapeChar; return(SqlProviderManifest.EscapeLikeText(argument, true, out usedEscapeChar)); }
public void GetProviderManifest_loads_ProviderManifest_xml() { TestReadResource( SqlProviderManifest.GetProviderManifest(), "ProviderManifest", @"http://schemas.microsoft.com/ado/2006/04/edm/providermanifest", x => x.Name == "Type" && x.GetAttribute("Name") == "geography", true); }
public void Can_get_type_from_name() { var providerManifest = new SqlProviderManifest("2008"); Assert.NotNull(providerManifest.GetStoreTypeFromName("nvarchar(max)")); Assert.NotNull(providerManifest.GetStoreTypeFromName("Datetime2")); Assert.NotNull(providerManifest.GetStoreTypeFromName("TINYINT")); }
internal XmlReader GetStoreSchemaDescription(string ssdlName) { if (this._version == SqlVersion.Sql8) { return(SqlProviderManifest.GetXmlResource("System.Data.Resources.SqlClient.SqlProviderServices." + ssdlName + "_Sql8.ssdl")); } return(SqlProviderManifest.GetXmlResource("System.Data.Resources.SqlClient.SqlProviderServices." + ssdlName + ".ssdl")); }
public void GetStoreSchemaMapping_loads_V3_schema_mapping_xml() { TestReadResource( SqlProviderManifest.GetStoreSchemaMapping("StoreSchemaMappingVersion3"), "Mapping", @"urn:schemas-microsoft-com:windows:storage:mapping:CS", x => x.Name == "EntitySetMapping" && x.GetAttribute("Name") == "FunctionReturnTableColumns", true); }
private static void FunctionsNotIncludedTest(string manifestToken, string[] notExpectedFunctions) { var actualFunctions = new SqlProviderManifest(manifestToken).GetStoreFunctions().Select(FunctionString).ToList(); foreach (var function in actualFunctions) { Assert.DoesNotContain(function, notExpectedFunctions); } }
public void Get_non_existing_type_throws() { var providerManifest = new SqlProviderManifest("2008"); const string typeName = "nvarchat"; Assert.ThrowsDelegate test = () => providerManifest.GetStoreTypeFromName(typeName); Assert.Equal( Strings.StoreTypeNotFound(typeName, providerManifest.NamespaceName), Assert.Throws<InvalidOperationException>(test).Message); }
private static void GetStoreTypesTest(string manifestToken, bool expectTypes) { var types = new SqlProviderManifest(manifestToken).GetStoreTypes(); var expectedCount = expectTypes ? 1 : 0; Assert.Equal(expectedCount, types.Count(t => t.Name.ToLowerInvariant() == "time")); Assert.Equal(expectedCount, types.Count(t => t.Name.ToLowerInvariant() == "date")); Assert.Equal(expectedCount, types.Count(t => t.Name.ToLowerInvariant() == "datetime2")); Assert.Equal(expectedCount, types.Count(t => t.Name.ToLowerInvariant() == "datetimeoffset")); Assert.Equal(expectedCount, types.Count(t => t.Name.ToLowerInvariant() == "geography")); Assert.Equal(expectedCount, types.Count(t => t.Name.ToLowerInvariant() == "geometry")); }
protected override XmlReader GetDbInformation(string informationType) { if (informationType == "StoreSchemaDefinitionVersion3" || informationType == "StoreSchemaDefinition") { return(this.GetStoreSchemaDescription(informationType)); } if (informationType == "StoreSchemaMappingVersion3" || informationType == "StoreSchemaMapping") { return(SqlProviderManifest.GetStoreSchemaMapping(informationType)); } if (informationType == "ConceptualSchemaDefinitionVersion3" || informationType == "ConceptualSchemaDefinition") { return((XmlReader)null); } throw new ProviderIncompatibleException(Strings.ProviderReturnedNullForGetDbInformation((object)informationType)); }
private EdmModel CreateTestModel() { var model = new EdmModel(DataSpace.SSpace); var sqlManifest = new SqlProviderManifest("2008"); var stringTypeUsage = sqlManifest.GetStoreType( TypeUsage.CreateDefaultTypeUsage( PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String))); var complexType = new ComplexType("Entity", "Unicorns420", DataSpace.SSpace); complexType.AddMember(new EdmProperty("NullableProperty", stringTypeUsage) { Nullable = true }); complexType.AddMember(new EdmProperty("NonNullableProperty", stringTypeUsage) { Nullable = false }); model.AddItem(complexType); return model; }
public void Can_get_and_set_provider_manifest() { var model = new EdmModel(DataSpace.SSpace); Assert.Null(model.ProviderManifest); var providerManifest = new SqlProviderManifest("2008"); model.ProviderManifest = providerManifest; Assert.Same(providerManifest, model.ProviderManifest); }
internal static XmlReader GetProviderManifest() { return(SqlProviderManifest.GetXmlResource("System.Data.Resources.SqlClient.SqlProviderServices.ProviderManifest.xml")); }
private void Initialize() { if (this._version == SqlVersion.Sql10 || this._version == SqlVersion.Sql11) { this._primitiveTypes = base.GetStoreTypes(); this._functions = base.GetStoreFunctions(); } else { List <PrimitiveType> primitiveTypeList = new List <PrimitiveType>((IEnumerable <PrimitiveType>)base.GetStoreTypes()); primitiveTypeList.RemoveAll((Predicate <PrimitiveType>)(primitiveType => { if (!primitiveType.Name.Equals("time", StringComparison.OrdinalIgnoreCase) && !primitiveType.Name.Equals("date", StringComparison.OrdinalIgnoreCase) && (!primitiveType.Name.Equals("datetime2", StringComparison.OrdinalIgnoreCase) && !primitiveType.Name.Equals("datetimeoffset", StringComparison.OrdinalIgnoreCase)) && !primitiveType.Name.Equals("geography", StringComparison.OrdinalIgnoreCase)) { return(primitiveType.Name.Equals("geometry", StringComparison.OrdinalIgnoreCase)); } return(true); })); if (this._version == SqlVersion.Sql8) { primitiveTypeList.RemoveAll((Predicate <PrimitiveType>)(primitiveType => { if (!primitiveType.Name.Equals("xml", StringComparison.OrdinalIgnoreCase)) { return(primitiveType.Name.EndsWith("(max)", StringComparison.OrdinalIgnoreCase)); } return(true); })); } this._primitiveTypes = new ReadOnlyCollection <PrimitiveType>((IList <PrimitiveType>)primitiveTypeList); IEnumerable <EdmFunction> source = base.GetStoreFunctions().Where <EdmFunction>((Func <EdmFunction, bool>)(f => !SqlProviderManifest.IsKatmaiOrNewer(f))); if (this._version == SqlVersion.Sql8) { source = source.Where <EdmFunction>((Func <EdmFunction, bool>)(f => !SqlProviderManifest.IsYukonOrNewer(f))); } this._functions = new ReadOnlyCollection <EdmFunction>((IList <EdmFunction>)source.ToList <EdmFunction>()); } }
public SqlProviderManifest(string manifestToken) : base(SqlProviderManifest.GetProviderManifest()) { this._version = SqlVersionUtils.GetSqlVersion(manifestToken); this.Initialize(); }
internal static XmlReader GetStoreSchemaMapping(string mslName) { return(SqlProviderManifest.GetXmlResource("System.Data.Resources.SqlClient.SqlProviderServices." + mslName + ".msl")); }