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

  Public Person GetPerson () {...} Public Person GetPersonWithOrders Pass a flag in the method (...) {...}   

Option 2

:

  Public Person GetPerson (bool getOrders) {...}   

Option 3

You can call the caller to query the data You can use it for

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -