예제 #1
0
        internal static DbProviderServices GetProviderServices(DbProviderFactory factory)
        {
            EDesignUtil.CheckArgumentNull(factory, "factory");

            // Special case SQL client so that it will work with System.Data from .NET 4.0 even without
            // a binding redirect.
            if (factory is SqlClientFactory)
            {
                return(SqlProviderServices.Instance);
            }

            IServiceProvider serviceProvider = factory as IServiceProvider;

            if (serviceProvider == null)
            {
                throw MetadataUtil.ProviderIncompatible(System.Data.Entity.Design.Strings.EntityClient_DoesNotImplementIServiceProvider(
                                                            factory.GetType().ToString()));
            }

            DbProviderServices providerServices = serviceProvider.GetService(typeof(DbProviderServices)) as DbProviderServices;

            if (providerServices == null)
            {
                throw MetadataUtil.ProviderIncompatible(
                          System.Data.Entity.Design.Strings.EntityClient_ReturnedNullOnProviderMethod(
                              "GetService",
                              factory.GetType().ToString()));
            }
            return(providerServices);
        }
예제 #2
0
        private void WriteTypeElement(EdmType type)
        {
            WriteErrorsComment(type);
            switch (type.BuiltInTypeKind)
            {
            case BuiltInTypeKind.EntityType:
                WriteEntityTypeElement((EntityType)type);
                break;

            case BuiltInTypeKind.AssociationType:
                WriteAssociationTypeElement((AssociationType)type);
                break;

            case BuiltInTypeKind.EdmFunction:
                WriteFunctionElement((EdmFunction)type);
                break;

            case BuiltInTypeKind.ComplexType:
                WriteComplexTypeElement((ComplexType)type);
                break;

            case BuiltInTypeKind.RowType:
                WriteRowTypeElement((RowType)type);
                break;

            default:
                throw EDesignUtil.NonSerializableType(type.BuiltInTypeKind);
            }
        }
예제 #3
0
 private void ValidateNamespace(string namespaceToWrite)
 {
     if (EdmItemCollection.IsSystemNamespace(MetadataItem.EdmProviderManifest, namespaceToWrite))
     {
         throw EDesignUtil.EdmReservedNamespace(namespaceToWrite);
     }
 }
        public void WriteXml(XmlWriter writer)
        {
            EDesignUtil.CheckArgumentNull(writer, "writer");

            WriteMappingStartElement(writer);
            WriteEntityContainerMappingElement(writer);
            writer.WriteEndElement();
        }
예제 #5
0
 internal static void CheckTargetEntityFrameworkVersionArgument(Version targetEntityFrameworkVersion, string parameterName)
 {
     EDesignUtil.CheckArgumentNull(targetEntityFrameworkVersion, parameterName);
     if (!EntityFrameworkVersions.IsValidVersion(targetEntityFrameworkVersion))
     {
         throw EDesignUtil.Argument(parameterName);
     }
 }
 internal OneToOneMappingSerializer(MappingLookups lookups,
                                    EntityContainer storeContainer,
                                    EntityContainer modelContainer,
                                    Version schemaVersion)
 {
     EDesignUtil.CheckArgumentNull(lookups, "lookups");
     EDesignUtil.CheckArgumentNull(storeContainer, "storeContainer");
     EDesignUtil.CheckArgumentNull(modelContainer, "modelContainer");
     _lookups        = lookups;
     _storeContainer = storeContainer;
     _modelContainer = modelContainer;
     _xmlNamespace   = EntityFrameworkVersions.GetSchemaNamespace(schemaVersion, DataSpace.CSSpace);
 }
예제 #7
0
        private void WriteEntityContainerElement(EntityContainer container)
        {
            _writer.WriteStartElement(XmlConstants.EntityContainer);
            _writer.WriteAttributeString(XmlConstants.Name, container.Name);

            //
            // Generate "annotation:LazyLoadingEnabled="true"" for model schema
            //
            if (_isModel && container.MetadataProperties.Contains(DesignXmlConstants.EdmAnnotationNamespace + ":" + DesignXmlConstants.LazyLoadingEnabled))
            {
                _writer.WriteAttributeString(
                    TranslateFacetNameToAttributeName(
                        DesignXmlConstants.LazyLoadingEnabled),
                    DesignXmlConstants.EdmAnnotationNamespace,
                    GetAttributeValueString(
                        container.MetadataProperties[DesignXmlConstants.EdmAnnotationNamespace + ":" + DesignXmlConstants.LazyLoadingEnabled].Value));
            }

            foreach (EntitySetBase set in container.BaseEntitySets)
            {
                switch (set.BuiltInTypeKind)
                {
                case BuiltInTypeKind.EntitySet:
                    WriteEntitySetElement((EntitySet)set);
                    break;

                case BuiltInTypeKind.AssociationSet:
                    WriteAssociationSetElement((AssociationSet)set);
                    break;

                default:
                    throw EDesignUtil.NonSerializableType(set.BuiltInTypeKind);
                }
            }

            foreach (EdmFunction functionImport in container.FunctionImports.Where(fi => fi.IsComposableAttribute))
            {
                WriteFunctionElement(functionImport);
            }

            _writer.WriteEndElement();
        }