locked
Adding Service Reference does not add Metadata? RRS feed

  • Question

  • Hi,

    I tried to us Json in a winforms app and consuming Lightswitch Odata.

    I updated WFC Data Service to the newest version with nuget package manager.

    Then I tried to Format.usejson, but I always got an error that there is no model and I need to give the method a parameter.

    With this code it worked:

    Uri Uri = new Uri("http://services.odata.org/V3/OData/OData.svc");
    
                Uri Urimeta = new Uri("http://services.odata.org/V3/OData/OData.svc/$metadata");
                var context = new Demoserviceref.DemoService(Uri);
    
                var xmlTextReader = new XmlTextReader(Urimeta.ToString());
                IEdmModel edmModel = null;
                IEnumerable<EdmError> errors = null;
                if (EdmxReader.TryParse(xmlTextReader, out edmModel, out errors))
                {
                    models[Urimeta] = edmModel;
                }
    
                context.Format.UseJson(models[Urimeta]);

    But I would like to now if there is a way to download the metadata when adding the service reference, because with this code I always have to load the metadata at the application start?

    Thanks.

    Markus

    Tuesday, October 22, 2013 9:39 PM