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

  • Home
  • SEARCH
  • 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 416727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:30:33+00:00 2026-05-12T18:30:33+00:00

I have the following expression in linq (its a join) and i am selecting

  • 0

I have the following expression in linq (its a join) and i am selecting into “J” because i need to use J later (currently i just selecting J but once i have this fixed i plan on use J within another subquery after)

But it won’t let me supply a where using the “V” side hence v.IdOFfice is invalid.
I have tried swapping around the joins and that what happens i can’t use the “GVT”..

WIth specifying the where it works perfect but i need to specify 2 wheres that are present in the 2 tables … hence IdOffice and IdTariff are in there own tables .. they are not both ….

(from gvt in Tariffs
join v in Items
on gvt.IdGroupItem equals v.IdGroupItem 
into j
where v.IdOffice == 1 && gvt.IdTariff == 111
select j).Take(50)

Probably something silly, it appears the table specified after the join i am not able to use in the where?

Any ideas?

Thanks

This is basically what i am trying to achieve

from gvt in Tariffs
  join v in Items
  on gvt.IdGroupItem equals v.IdGroupItem 
  into j
  where v.IdOffice == 1 && gvt.IdTariff == 111
  select new
  {
      id = v.IdItem
      Tariff = from j
      {
    test = j.TariffDesc,
        test1 = j.TariffPrice
      }

basicaly i end up with 1 record with Id and a field which as many tariffs inside – if this makes sense?

}

Query working great,

it would be nice to be able to use an extension method (c#) like so … is this possible so i can dynamically set tariff … so for example i do the query and i have an extension method (which i already use on simple queries) like so

    public static IQueryable<Models.ItemTariffCol> WithTariffId(this IQueryable<Models.ItemTariffCol> qry, int tariffId)
    {
        return from t in qry
               where t.IdTarifa == tariffId
               select t;
    }

this makes it very extensible ? If its a normal where i can do this but the query isn’t in the where

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-05-12T18:30:33+00:00Added an answer on May 12, 2026 at 6:30 pm

    You’re doing a group join here, since you’re using into. This means that for every gvt, you have not one Item, but possibly several (or none). The list of all items is stored in j, as an IEnumerable<Item>. If you want to select all tariffs for which there’s at least one item with IdOffice == 1, then you can do it like this:

    from gvt in Tariffs
    join v in Items
         on gvt.IdGroupItem equals v.IdGroupItem 
         into j
    where gvt.IdTariff == 111 && j.Any(v => v.IdOffice == 1)
    ...
    

    After the answer edit, it seems that you’ve started from the wrong direction as well – so far as I can see, you want a list of tariffs for every item, not the list of items for every tariff. For that, you need to reverse your join:

    from item in Items
    join tariff in Tariffs
         on item.IdGroupItem equals tariff.IdGroupItem 
         into tariffs
    where item.IdOffice == 1
    select new
    {
        Id = item.IdItem,
        Tariffs = from tariff in tariffs
                  where tariff.IdTariff == 111
                  select new { tariff.TariffDesc, tariff.TariffPrice }
    }
    

    Or you could filter tariffs right in the join:

    from item in Items
    join tariff in (from t in Tariffs where t.IdTariff == 111 select t)
         on item.IdGroupItem equals tariff.IdGroupItem 
         into tariffs
    where item.IdOffice == 1
    select new
    {
        Id = item.IdItem,
        Tariffs = from tariff in tariffs
                  select new { tariff.TariffDesc, tariff.TariffPrice }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have code which produces the following LINQ expression (taken from the WhoCanHelpMe
I have the following code: using System; using System.Linq; using System.Linq.Expressions; public class Program
I have the following string expression in a PowerShell script: select count(*) cnt from
I have the following regular expression : I figured out most of the part
I have the following regex expression to match html links: <a\s*href=['|](http:\/\/(.*?)\S['|]> it kind of
I have a validation control that has the following expression: (?=(.*\\d.*){2,})(?=(.*\\w.*){2,})(?=(.*\\W.*){1,}).{8,} That's a password
I have the following very simple Javascript-compatible regular expression: <script type=text/javascript id=(.+) src=([^]+)> I
I have the following string: cn=abcd,cn=groups,dc=domain,dc=com Can a regular expression be used here to
I have a method which have this signature public static IList<T> GetBy<T>(System.Linq.Expressions.Expression<Func<T, bool>> expression)
I have the following SQL query: SELECT C.ID, C.Name FROM Category C JOIN Layout

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.