entity framework - Foreign Keys in Web API 2 - Best practices? -
Actually I am writing an API using Web API 2 and entity framework on backend.
Say I got the person property with the foreign key for the order property. Sometimes the customer needs a person's property, sometimes it does not happen. How should I go about this? Should I build two ways: / API / Individual / 1 & lt; - without any orders / APIs / individualists / 1 & lt; Orders the person In my opinion, it seems like a lot of ways. I know that the queryable attribute exists that provides support for the client, which uses the $ argument to include the assets - although if I can escape from it I will not use query attribute. What are your suggestions? From the top of my head, there are some options. Option 1 Many methods in API Option 2 : Option 3 You can call the caller to query the data You can use it for
Public Person GetPerson () {...} Public Person GetPersonWithOrders Pass a flag in the method (...) {...}
Public Person GetPerson (bool getOrders) {...}
Comments
Post a Comment