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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:05:00+00:00 2026-06-14T15:05:00+00:00

I have two Classes (given via Entity Framework) which are in a many to

  • 0

I have two Classes (given via Entity Framework) which are in a many to many relationship:

Corporation which has the member Tags

Tag which has the member name

The EntityDataSource gives me the ObjectQuery which i want to filter in a given tagname but i don’t know how. I want to get all corporations, which have a tag with the name “myname”. I don’t know how to do the linq query

When i query the entities i unfortunately don’t get an Objectquery.

protected void EntityDataSource1_QueryCreated(object sender, QueryCreatedEventArgs e)
{
    // first try
    var corps = e.Query.Cast<Corporation>(); 
    // of course doesn't work, because oyu can't access a member (name) of a collection (Tags) 
    // i don't know the right linq expression for this
    e.Query = from c in corps where c.Tags.Name.Contains("myname") select c; 

    // second try
    var tags = from t in entities.Tags where t.Name.Contains("myname") select t;
    var filteredcorporations = from c in tags select c.Corporations;
    // does not work because it is not a ObjectQuery<Corporation>
    e.query = filteredcorporations; 
}

My EntityDataSource:

<asp:EntityDataSource ID="EntityDataSource1" runat="server" ConnectionString="name=eodbEntities" DefaultContainerName="eodbEntities" EnableFlattening="False" EntitySetName="Corporations" OnQueryCreated="EntityDataSource1_QueryCreated">
</asp:EntityDataSource>
  • 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-14T15:05:02+00:00Added an answer on June 14, 2026 at 3:05 pm

    You can do it in markup:

    <asp:EntityDataSource ID="EntityDataSource1" runat="server" 
        ConnectionString="name=eodbEntities" 
        DefaultContainerName="eodbEntities" EnableFlattening="False" 
        EntitySetName="Corporations" Select=""
        Where="it.Tags.Name.Contains(@tagname)">
        <WhereParameters>
            <asp:ControlParameter DefaultValue="myname" DbType="String" Name="tagname"/>
        </WhereParameters>
    </asp:EntityDataSource>
    

    Or

    <asp:EntityDataSource ID="EntityDataSource1" runat="server" 
        ConnectionString="name=eodbEntities" 
        DefaultContainerName="eodbEntities" EnableFlattening="False"    
        EntitySetName="Corporations" Select=""
        Where="it.Tags.Name.Contains(&quote;tagname&quote;)">   
    </asp:EntityDataSource>
    

    For more information you can read here

    Update:

    Your query cannot be done in markup:( Then try this:

    protected void EntityDataSource1_QueryCreated(object sender, QueryCreatedEventArgs e)
    {
        var productQuery1 = e.Query.OfType<Corporation>();
        e.Query = productQuery1.Where(c => c.Tags.Any(t => t.Name.Contains("myname")));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two classes in Grails application , Employee has hasMany(one To Many relations)
I need to have two classes, one class has two methods each of which
Given two model classes, Foo and Bar , I want Foo to have 3
I have two classes (MVC view model) which inherits from one abstract base class.
I have two classes which represent a special kind of numeric value. Let's call
I have two classes, Test2 and Test3. Test2 has an attribute test3 that is
I have created two partial classes for a web page. Now i have given
I have implemented the two classes shown at http://tomcat.apache.org/tomcat-6.0-doc/aio.html which gives a messenger application
Suppose we have the two classes given below: public class baseclass implements interface {}
I have two classes: A and B. Each A has an ordered ranking of

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.