Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DataServiceContext can't work with POCO's due to Missing IEdmModel #1614

Merged
merged 11 commits into from
Feb 27, 2020

Conversation

marabooy
Copy link
Member

@marabooy marabooy commented Dec 23, 2019

Issues

*This pull request fixes issue #1003 *

Description

Introduces a new action to load the metadata from the metadata Url and set the ServiceModel. The new action runs to load the metadata if the metadata had not been set before (directly by calling context.Format.UseJson(ServiceModel) or using a user provided Hook context.Format.LoadServiceModel.
This would allow people to use the syntax below to use this method in their code when not using the code generation tools or when they want to use the latest model in their code. E.g when developing new API's or when working on API's that do not publish breaking changes.
This does not negatively impact client code generated using the tools (codegen and connected service) as they provide the ServiceModel directly or provide a Hook using the exposed context.Format.LoadServiceModel property
. Existing users of OData Client also needed to have the service model set in order for it to function properly.

// POCO class
public class Person
{
        public string Id { get; set; }
        public string UserName { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
}
// Dataservice context
 public class Container : DataServiceContext
{
 public Container(Uri serviceRoot) : 
                base(serviceRoot)
        {
              this.People = base.CreateQuery<Person>("People");
        }
   public DataServiceQuery<Person> People {get; private set;}
}

...
// usage
var context = new Container(uri);
var people= context.People;

 foreach (var person in people)
 {
           Console.WriteLine(person.UserName);
  }

Checklist (Uncheck if it is not completed)

  • Test cases added
  • Docs added
  • Build and test with one-click build and test script passed

Additional work necessary

Docs Needed

  • Update the dataservice context usage docs to reflect how to use the DataServiceContext without using codegen tools.
  • Update documentation to show how to override this behaviour for running test cases or implementing custom logic using the two methods highlighted in the earlier section LoadServiceModel and UseJson when one wants to ship the EDMX model together with the client, e.g in Codegen

@marabooy marabooy changed the title added somne config changes [Draft] Fix DataServiceContext can't work with POCO's due to Missing IEdmModel Jan 8, 2020
@marabooy marabooy marked this pull request as ready for review January 15, 2020 11:57
@marabooy marabooy requested review from xuzhg and odero January 15, 2020 11:57
@marabooy marabooy changed the title [Draft] Fix DataServiceContext can't work with POCO's due to Missing IEdmModel Fix DataServiceContext can't work with POCO's due to Missing IEdmModel Jan 16, 2020
@marabooy marabooy force-pushed the fixing-poco branch 2 times, most recently from 4b978b4 to 0e32792 Compare January 22, 2020 13:02
@marabooy marabooy requested a review from odero January 31, 2020 10:31
@marabooy marabooy requested a review from habbes February 4, 2020 11:24
@marabooy marabooy requested review from g2mula and habbes February 19, 2020 16:00
marabooy added a commit to marabooy/OData-docs that referenced this pull request Feb 27, 2020
marabooy added a commit to marabooy/OData-docs that referenced this pull request Feb 27, 2020
marabooy added a commit to marabooy/OData-docs that referenced this pull request Feb 27, 2020
@marabooy marabooy merged commit a0fc496 into OData:master Feb 27, 2020
@marabooy marabooy deleted the fixing-poco branch February 27, 2020 13:32
KanishManuja-MS pushed a commit to KanishManuja-MS/odata.net that referenced this pull request Mar 24, 2020
OData#1614)

Added changes to DataServiceClientFormat to load edm model from network for certain cases
and updated tests and regression tests for failing test cases
 Closes OData#1003
KanishManuja-MS pushed a commit that referenced this pull request Mar 24, 2020
#1614)

Added changes to DataServiceClientFormat to load edm model from network for certain cases
and updated tests and regression tests for failing test cases
 Closes #1003
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants