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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:58:56+00:00 2026-05-31T14:58:56+00:00

I have a general question about the interaction of linq with an entityquery and

  • 0

I have a general question about the interaction of linq with an entityquery and ria services. I know that within my domainconext I can define queries for my application. For example, I can use linq within my domaincontext to define the following query:

    public IQueryable<User> GetUsersFriends(Guid usersID)
    {
        return (from f in this.ObjectContext.Friends join u in this.ObjectContext.Users on f.FriendUsersID equals u.ID where f.UsersID.Equals(usersID) select u);
    }

This is all good. But my question is, can I perform the same type of query from the client side (silverlight app) ? So can I do build a linq statement against an EntityQuery object and return data from the database in this fashion?

I know that I can perform linq operations on the collections of entities that already have been loaded? Can I use linq on the client side to load the collections?

I am thinking that all queries that ultimately hit the database need to be defined in my domain context? Out of force of habit I keep trying to use linq to define new queries and pass those to the domaincontext.load() operation….which fails miserably. The domainconext probably doesn’t have any way to marshal the queries across the line…right?

Is my understanding correct? If someone could help verify this for me, I would appreciate it.

  • 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-31T14:58:57+00:00Added an answer on May 31, 2026 at 2:58 pm

    One of the main advantages of IQueryable (and it’s also a pretty good security risk), is that you CAN create a query on the client side, and serialize it back to the server for processing on the serve. The requirement here is that it must return the type that is defined (in your case IQueryable where User is the type that must returned in a collection that supports IEnumerable<>.

    I took my example from Shawn Wildermuth (wildermuth.com), and tweaked it a little. This is what I use in my client side “model”.

    publicvoid PerformQuery<T>(EntityQuery<T> qry, EventHandler<EntityResultsArgs<T>> evt, object pUserState = null, bool NoRecordsThrow = False, LoadBehavior pLoadBehavior = LoadBehavior.MergeIntoCurrent ) where T : Entity
    {
    
      ModelDataContext.Load<T>(
        qry,
        pLoadBehavior,
        r =>
        {
    
          if (evt != null)
          {
            try
            {
    
              if (r.HasError)
              {
    
    #if DEBUG
    
                System.Diagnostics.Debugger.Break();
    
    #endif
                //internal class to record error messages
                AppMessages.ErrorMessage.Display(string.Concat(r.Error.Message, Environment.NewLine, "------------------------", "------- Stack Trace ------", Environment.NewLine, r.Error.StackTrace));
              }
              else if (r.Entities.Count() > 0 || NoRecordsThrow)
                evt(this, new EntityResultsArgs<T>(r.Entities, r.UserState));
            }
            catch (Exception ex)
            {
    #if DEBUG
              System.Diagnostics.Debugger.Break();
    #endif
              evt(this, new EntityResultsArgs<T>(ex));
            }
          }
        },
        pUserState);
    }
    

    When I would then use it like this:

    var UserQuery =  <DomainServiceName>.Users.Where(pUser => pUsers.City == "Calgary");
    PerformQuery<User>(UserQuery, UserQueryComplete)
    

    The downside is that via this one endpoint, User data can be extracted with any kind of filter that is issued on the client side….

    HTH,
    Richard

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

Sidebar

Related Questions

I have a general question about the way that database indexing works, particularly in
I have a general question about rails controllers/models: I have a model Providers, that
I have one general question about optimization at SQL Server: How I can reduce
I'm about to start using location services, but have a general question about how
I have a general question, and curiosity about LINQ and timeouts. I have a
i have a general question about how sql server evaluates the joins.The query is
i have a general question about properties and ivars. ive seen many different examples
I have a general question for the group. I am about to start a
I have a question about the Microsoft PPL library, and parallel programming in general.
I have a general question that is rather open-ended (i.e. depends on platform, application

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.