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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:31:01+00:00 2026-05-20T16:31:01+00:00

So I posted this earlier.: IAsyncRepository or IObservableRepository for silverlight 4 + WCF Data

  • 0

So I posted this earlier.:
IAsyncRepository or IObservableRepository for silverlight 4 + WCF Data Services

I’ve been working on an AsyncRepo for Silverlight so I’ve just got stuck at a small place.

The code is just for the explanation…scroll to bottom for the culprit code.

I have a repo defined like this:

public interface IAsyncRepository<T> where T : class
{
    void GetById(int id, Action<T> callback);
    void GetAllFromQuery(Func<MyEntities, IQueryable<Product>> funcquery, Action<IList<Calculator>> callback)
}

I’m using WCF Data Services + Linq to Entities. The first one works perfect like this:

    public void GetById(int id, Action<Product> callback)
    {
        MyEntities dat = new MyEntities(new Uri(..url..));
        var query = from c in dat.Products where c.ID == id select c;//WATCH THIS
        allQuery = new DataServiceCollection<Product>(dat);
        allQuery.LoadAsync(query);
        allQuery.LoadCompleted += (obj, evt) =>
            {
                if (allQuery == null)
                {
                    callback(null);
                }
                else
                {
                    callback(allQuery.FirstOrDefault());
                }
            };
    }

Now to the second method:

If you notice in the above method, I have a linq query I use to get the data. In my second repo method, I want to pass this query from the consumer into the method.

So now..

    public void GetAllFromQuery(Func<MyEntities, IQueryable<Product>> funcquery, Action<IList<Product>> callback)
    {
        MyEntities dat = new MyEntities(..uri..);
        allQuery = new DataServiceCollection<Product>(dat);
        allQuery.LoadAsync(funcquery(dat));
        allQuery.LoadCompleted += (obj, evt) =>
        {
            if (allCalcQuery == null)
            {
                callback(null);
            }
            else
            {
                callback(allQuery.ToList());
            }
        };
    }

No problem so far… until…

I use it like this:

        repo.GetAllFromQuery(
            x => from p in x.Products where p.ID > 5 select p,
            y => Assert.IsTrue(y.Count > 0));

This gives me :

cannot convert from 'lambda expression' to System.Func<MyEntities,IQueryable<Product.Calculator>>'

I will truly respect someone who gives me any solution. This has given me programmers block all day today!

  • 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-20T16:31:02+00:00Added an answer on May 20, 2026 at 4:31 pm

    EDIT: Okay, now the typo’s fixed, try the non-query version (which I think is simpler anyway):

    repo.GetAllFromQuery(
        x => x.Products.Where(p => p.ID > 5),
        y => Assert.IsTrue(y.Count > 0));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I posted this earlier and got some help but still no working solution.
I posted this earlier on wordpress.stackexchange.com. However, never got a reply. Hence, trying my
I posted earlier about how to do this, and got some great replies, and
This is related to a question i posted earlier.I am still stuck on it.Heres
I had posted this earlier on Stack Overflow, but couldn't get a positive result.
Sorry guys, I posted this earlier today where my add as linked images were
I need to find the maximum route of a triangle. I earlier posted this
I posted a thread about this earlier and have made some progress but now
This is a related question to one I posted earlier... I'm trying to sum
This is a follow-up to an earlier question I posted on EF4 entity keys

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.