Created
June 30, 2014 08:34
-
-
Save ODataTeam/e12b7b3d7aded112ad61 to your computer and use it in GitHub Desktop.
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; | |
} | |
}; | |
using (Stream csdlStream = File.Open("MainModel.csdl", FileMode.Open)) | |
{ | |
bool parseResult; | |
IEnumerable<EdmError> errors; | |
parseResult = EdmxReader.TryParse(XmlReader.Create(csdlStream), getReferencedSchemaFunc, out model, out errors); | |
if (!parseResult) | |
{ | |
throw new InvalidOperationException("Failed to load model : " + string.Join(Environment.NewLine, errors.Select(e => e.ErrorMessage))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment