GithubHelp home page GithubHelp logo

Comments (5)

meancrazy avatar meancrazy commented on June 12, 2024

Driver has a method .Expand(...). You can use it like

Products.Expand(product => product.Supplier).ToList();

See also http://www.odata.org/getting-started/basic-tutorial/#expand

from linqpadodata4.

michaelaltmann avatar michaelaltmann commented on June 12, 2024

Thanks. Is there a way to force it to use urls of the form

Product(3)/Supplier 

rather than

Product?$expand=Supplier

I need this because the relationship is defined in the OData model, but not in the Product CLR type on the server side. My controller does have a GetSupplier method would provide the related supplier.

from linqpadodata4.

meancrazy avatar meancrazy commented on June 12, 2024

Sure,

Products.Where(p => p.ID == 3).Select(p => p.Supplier).Single()

from linqpadodata4.

michaelaltmann avatar michaelaltmann commented on June 12, 2024

Thanks. That does use the Product(3)/Supplier URL when the Product class has a property called Supplier. However, in my real application where I am building up the EDM model manually and adding the navigational property manually without having the Supplier property, LinqPad only makes a call to Product(1). Any ideas? Here is the code I am using to build the EDM model relationship.

EdmNavigationPropertyInfo info = new EdmNavigationPropertyInfo();
            info.Name = relationshipName;
            info.Target = sourceEntityType;
            info.TargetMultiplicity = EdmMultiplicity.Many;
            EdmNavigationProperty navigation =
            sourceEntityType.AddUnidirectionalNavigation(info);
            sourceEntitySet.AddNavigationTarget(navigation, targetEntitySet);

from linqpadodata4.

meancrazy avatar meancrazy commented on June 12, 2024

Correct me: Your model has one Product entity set, two entity definitions Product and Supplier and the Product entity has an Supplier property. And there is no Supplier entity set?

from linqpadodata4.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.