This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| IEdmModel model; | |
| Func<Uri, XmlReader> getReferencedSchemaFunc = uri => | |
| { | |
| return XmlReader.Create(GetModelStream(uri)); | |
| }; | |
| ODataMessageReaderSettings readerSettings = new ODataMessageReaderSettings() { BaseUri = new Uri(ServiceBaseUri) }; | |
| using (var msgReader = new ODataMessageReader((IODataResponseMessage)message, readerSettings)) | |
| { | |
| model = msgReader.ReadMetadataDocument(getReferencedSchemaFunc); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using (var msgWriter = new ODataMessageWriter((IODataResponseMessage)message, writerSettings, mainModel)) | |
| { | |
| msgWriter.WriteMetadataDocument(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| IEdmModel model; | |
| Func<Uri, XmlReader> getReferencedSchemaFunc = uri => | |
| { | |
| if (uri.AbsoluteUri.EndsWith("ReferencedModel.csdl")) | |
| { | |
| return XmlReader.Create(File.Open("ReferencedModel.csdl", FileMode.Open)); | |
| } | |
| else | |
| { | |
| return null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| EdmReference refModel = new EdmReference(string.Format("{0}ReferencedModel.csdl", ServiceBaseUri)); | |
| refModel.AddInclude(new EdmInclude("RefModel", "SampleCode.ReferencedModel")); | |
| mainModel.SetEdmReferences(new IEdmReference[] { refModel }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| EdmModel mainModel = new EdmModel(); | |
| var mainContainer = new EdmEntityContainer(mainNS, "MainContainer"); | |
| var customerType = new EdmEntityType(mainNS, "Customer", (IEdmEntityType)personType); | |
| customerType.AddProperty(new EdmStructuralProperty(customerType, "HomeAddress", new EdmComplexTypeReference((IEdmComplexType)addressType, true))); | |
| mainModel.AddElement(customerType); | |
| var customerSet = new EdmEntitySet(mainContainer, "Customers", customerType); | |
| mainContainer.AddElement(customerSet); | |
| mainModel.AddElement(mainContainer); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| IEnumerable<IEdmOperation> FindDeclaredBoundOperations(string qualifiedName, IEdmType bindingType); | |
| IEnumerable<IEdmOperation> FindDeclaredOperations(string qualifiedName); | |
| IEdmValueTerm FindDeclaredValueTerm(string qualifiedName); | |
| IEnumerable<IEdmVocabularyAnnotation> FindDeclaredVocabularyAnnotations(IEdmVocabularyAnnotatable element); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var addressType = referencedModel.FindDeclaredType(string.Format("{0}.Address", refNS)); | |
| var personType = referencedModel.FindDeclaredType(string.Format("{0}.Person", refNS)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| IEdmModel referencedModel; | |
| using (Stream csdlStream = File.Open("ReferencedModel.csdl", FileMode.Open)) | |
| { | |
| bool parseResult; | |
| IEnumerable<EdmError> errors; | |
| parseResult = EdmxReader.TryParse(XmlReader.Create(csdlStream), out referencedModel, out errors); | |
| if (!parseResult) | |
| { | |
| throw new InvalidOperationException("Failed to load model : " + string.Join(Environment.NewLine, errors.Select(e => e.ErrorMessage))); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"> | |
| <edmx:Reference Uri="http://www.example.com/ReferencedModel.csdl"> | |
| <edmx:Include Namespace="SampleCode.ReferencedModel" Alias="RefModel" /> | |
| </edmx:Reference> | |
| <edmx:DataServices> | |
| <Schema Namespace="SampleCode.MainModel" xmlns="http://docs.oasis-open.org/odata/ns/edm"> | |
| <EntityType Name="Customer" BaseType="SampleCode.ReferencedModel.Person"> | |
| <Property Name="HomeAddress" Type="SampleCode.ReferencedModel.Address" /> | |
| </EntityType> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0"> | |
| <edmx:DataServices> | |
| <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="SampleCode.ReferencedModel"> | |
| <ComplexType Name="Address"> | |
| <Property Type="Edm.String" Name="Street" Nullable="false"/> | |
| <Property Type="Edm.String" Name="City" Nullable="false"/> | |
| <Property Type="Edm.String" Name="PostalCode" Nullable="false"/> | |
| </ComplexType> | |
| <EntityType Name="Person"> | |
| <Key> |
NewerOlder