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 8954631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:21:04+00:00 2026-06-15T14:21:04+00:00

I just started to learn some Odata and I need help at some queries

  • 0

I just started to learn some Odata and I need help at some queries I made.

Let’s take 2-3 examples of Linq queries. (NOTE: List of queries )

      1) var one  =  Users.Single(s => s.ID == 1).Sources.Where(s =>s.Genre.Name == "Sport").ToList();

      2) var second = TvSchedules.Where(s => s.Date.Day == DateTime.Today && s.Source.Type == "Channel"). Select(s => new {s.Media.Title,s.Media.Details.Description,s.Media.Images.FirstOrDefault(a=>a.ID==s.Media.ID).Link, s.Source.Sign}).ToList();

      3) var third = TvSchedules.Where(s => s.Date < week && s.Media.Metadata.Select(a => a.IsHD).Contains(true)).Select(s => new { s.Media.Title, s.Media.Details.Description, s.Media.Images.FirstOrDefault().Link, s.Media.Metadata.FirstOrDefault().PriceSD, s.Media.RTRating }).ToList();

What are those queries for ? ( NOTE: Explaining list of queries )

1) I am selecting all Sources from User with ID=1 where source genre = 'Sport' ( I use User and Sources database tables )

2) I am querying only TVSchedules from Today where TVSchedules.Sources.Name = 'Channel' and I am selecting from TvSChedules.Media ( Title ), TvSchedules.Media.Details( Description), TvSchedules.Media.Images( Link ), TvSchedules.Source.Sign       

  In TvSchedules database table I have 2 FK ( MediaID, SourceID )

3) Like the second one, but I add some filters. I want to check if TvSchedules.Media.Metadata.isHd ==true 

My problems (NOTE: Problems based on queries above )

Problem A) Are those queries correct in Linq? I’m not sure about Many-to-Many relationships.

For example in the third example where I have a many-to-many relation beetween Media and Metadata ( TvSchedules.Where(s => s.Date < week && s.Media.Metadata.Select(a => a.IsHD).Contains(true)) ) . I need to select only TvSchedules that have date < week and Media.Metada.isHd=true .

My TvSchedules table looks like this

ID     MediaID    SourceID   Date
--     ------     --------   ----

Problem B) How can I translate those queries in ODATA ( Open data protocol ) queries ?

    1)  /Users(1)/AvailableSources?&filter=Genres eq 'Sport'
    2)  /TvSchedules?&filter=Date eq '@today'?$expand=Media,Details,Images?$select=Title,Description,Link 
    3) ?

Thank you

  • 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-15T14:21:05+00:00Added an answer on June 15, 2026 at 2:21 pm

    That kind of queries, except the first one, are syntactically and semantically correct but they are also problematic for readability, performance and because it is hard to compose the odata filter criteria.

    I walked that road and more you go forward, more pain to feel. My recommendation is to create sql views for they:

    1. it is ok because it´s simple.
    2. create a Today_TV_Schedule sql view
    3. create a Today_HDTV_Schedule (it uses the Today_TV_Schedule)

    After this, map your entities and you will be able to make it easier:

    var second = TvSchedules;
    var third = HdTvSchedules;
    

    OData queries will be easier too. Please consider my recommendation.

    Good luck!

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

Sidebar

Related Questions

I just started to learn python, so I need some help. I have closeparams.txt
I'm new to using Linq and just started a side project to learn some
I just started to learn about mod rewrite process. Now, I got some problems
I have just started to learn how to code iOS apps. I have made
I've just started my adventure with Cassandra database. I've managed to learn some basics
I just started doing jQuery last week, and so far I already made some
I've just started to learn Drupal and decided to implement a simple Student list
i just started to learn struts(+spring) MVC, and I could use some explanation of
OK so i just started to learn vb and did some experimenting until i
I just started to learn how to use action listeners. To my understanding it

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.