Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7982079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:34:11+00:00 2026-06-04T10:34:11+00:00

I got two controllers; ProjectController and DocumentController. One project can have several documents. If

  • 0

I got two controllers; ProjectController and DocumentController. One project can have several documents.

If I want to get documents by projectid, how and where should that be done using REST? (In general I havent got how REST deals with related data)

Edit: Found MVC Web API, get sub items that might be what I’m looking for.

Ivar

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T10:34:13+00:00Added an answer on June 4, 2026 at 10:34 am

    I believe this should be done in the DocumentController. Below is an example

    public class DocumentController : ApiController {
    
        public IQueryable<Document> GetDocs() 
        {
    
            //get db context 
    
                return db.documents;
    
        }
    
        public ICollection<Document> Get(int id)
        {
            return db.documents.where(d = d.ProjectId == id);
    
        }
    
    }
    

    The IQuerable version can be queried using odata filter query. like below:

    http://server:port/api/Document/getdocs?$filter=ProjectId eq ‘1'
    http://server:port/api/Document/getdocs?$filter=DocumentId eq ‘1001'
    

    (you will have to modify the MapHttpRoute to register this route)

    The get version (second function) will simply return collection based on the project id.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

so i have got two models with each one controller: Model Project has_many Themes
I've got two view controllers that have some similar function. Some of them are
I want to have one model & view that is served by multiple controllers
I have got two models, seen below, and am trying to insert one of
I've got a two controllers one with uclinux, second without any os. They are
I have two tableview controllers showing CoreData objects. One is a detail view (with
I have got a method in my MVC 3 controller class, that accepts two
I got two projects running, both written in PHP. Now I want to merge
I got two tables, one of which is a helper of the other. The
Say I got two Controllers like this Table1sController , and Table2sController . With corresponding

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.