Exemplo n.º 1
0
        internal static bool IsSqlFamilyProvider(this EFArtifact thisArtifact)
        {
            Debug.Assert(thisArtifact != null, "thisArtifact != null");

            // This is needed to workaround problems with facet propagation feature.
            // For Sql Server and Sql Server CE facets on properties in S-Space are by default
            // the same as facets on corresponding properties in C-Space and therefore it is possible
            // to blindly (i.e. wihtout asking the provider) propagate facets from S-Space properties
            // to C-Space properties. Providers for other databases may use facets to distinguish among
            // different types in which case the mismatch between facets on C-Space properties and S-Space
            // properties is intentional and facet propagation breaks this. In general we should always ask
            // the provider about the type before we propagate facet values. This is a major change though
            // so for now we will limit the default facet propagation to SqlServer and Sql Server CE only.
            var storageModel = thisArtifact.StorageModel();

            if (storageModel != null &&
                storageModel.Provider != null &&
                storageModel.Provider.Value != null)
            {
                return(storageModel.Provider.Value.Equals("System.Data.SqlClient", StringComparison.Ordinal) ||
                       storageModel.Provider.Value.StartsWith("System.Data.SqlServerCe", StringComparison.Ordinal));
            }

            return(false);
        }
Exemplo n.º 2
0
        internal static string GetSsdlAsString(this EFArtifact artifact)
        {
            Debug.Assert(artifact != null, "Artifact is null ");
            if (artifact != null)
            {
                return(GetSchemaFromRuntimeModelRoot(artifact.StorageModel()));
            }

            return(String.Empty);
        }
Exemplo n.º 3
0
        internal static string GetProviderManifestToken(this EFArtifact artifact)
        {
            var storageModel = artifact.StorageModel();

            if (storageModel != null &&
                storageModel.ProviderManifestToken != null)
            {
                return(storageModel.ProviderManifestToken.Value);
            }

            Debug.Fail("Unable to determine the provider manifest token for the SSDL");

            return(String.Empty);
        }
        internal static void ProcessStoredProcedureReturnTypeInformation(
            EFArtifact artifact,
            Dictionary<EntityStoreSchemaFilterEntry, IDataSchemaProcedure> newFunctionSchemaProceduresMap, IList<Command> commands,
            bool shouldCreateComposableFunctionImports)
        {
            if (null == artifact)
            {
                Debug.Fail("null artifact");
                return;
            }

            if (null == newFunctionSchemaProceduresMap)
            {
                Debug.Fail("Null newFunctionSchemaProceduresMap for artifact " + artifact.Uri);
                return;
            }

            var sem = artifact.StorageModel();
            if (null == sem)
            {
                Debug.Fail("Null StorageEntityModel for artifact " + artifact.Uri);
                return;
            }

            var storageEntityContainerName = sem.FirstEntityContainer.LocalName.Value;
            if (string.IsNullOrWhiteSpace(storageEntityContainerName))
            {
                Debug.Fail("Null or whitespace StorageEntityContainerName for artifact " + artifact.Uri);
                return;
            }

            foreach (var entry in newFunctionSchemaProceduresMap.Keys)
            {
                var schemaProcedure = newFunctionSchemaProceduresMap[entry];
                Command cmd = null;
                if (null == schemaProcedure)
                {
                    // schemaProcedure information was not collected - so delete the Function
                    var dbObj = DatabaseObject.CreateFromEntityStoreSchemaFilterEntry(entry, storageEntityContainerName);
                    var func = ModelHelper.FindFunction(sem, dbObj);
                    Debug.Assert(func != null, "Could not find Function to delete matching Database Object " + dbObj.ToString());
                    if (null != func)
                    {
                        cmd = func.GetDeleteCommand();
                    }
                }
                else
                {
                    cmd = new CreateMatchingFunctionImportCommand(schemaProcedure, shouldCreateComposableFunctionImports);
                }

                if (null != cmd)
                {
                    commands.Add(cmd);
                }
            }
        }