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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:52:12+00:00 2026-05-13T19:52:12+00:00

I have a problem in architecting my application. I have the following structure with

  • 0

I have a problem in architecting my application.

I have the following structure with only important aspects shown.

namespace Domain
{
   public class Invoice
   {
     //properties
   }

public class InvoiceRepository
{
   public Linq2SqlContext context = new Linq2SqlContext();

   public IQueryable<Invoice> GetInvoices()
   {
              var query = from inv in _dbctx.Invoices orderby inv.invInvoiceDate descending select GetInvoice(inv) ;

            return query;

   }
}
public class InvoiceService()
{
   public InvoiceRepository _repository = new InvoiceRepositroy();
   public IQueryable<Invoice> GetInvoices()
   {
      return _repository.GetInvoices();
   }   

}
}

namespace MyApp
{
   public class UI
   {
      public InvoiceService _service =  new InvoiceService();
      public void FilterInvoices()
      {
            var query =
                   (
                     from i in _service.GetInvoices()
                     from s in _service.GetStatuses()
                     where i.ProjectID == _projectid &&
                           s.ID == i.Status
                     select new
                     {
                         InvoiceID = i.ID,
                         DocumentTotal = i.TotalDue.ToString(),
                         Created = i.Created,
                         WeekEnding = i.WeekEnding,
                         Status = s.staStatus
                     }
                   ).Skip(_pageIndex * _pageSize).Take(_pageSize);

      }

   }
{

So I want to return IQueryable from my service so I can
filter from client code. But the problem I’m coming up with
is the FilterInvoices method errors with “No supported
translation to sql” because of the GetInvoice method
which is iused to return an Invoice entity (this is
a layer on top op the LInq2 sql layer) and not an Linq2sql Invoice entity.

So how do I return a IQueryable from my service with this structure??
Also how do I sort and return a IQureyable in repository GetInvoices.

Hope this makes sense.

Malcolm

  • 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-13T19:52:12+00:00Added an answer on May 13, 2026 at 7:52 pm

    linq2sql thinks GetInvoice (within GetInvoices) is a stored procedure. One way around it

    var query = from inv in _dbctx.Invoices orderby inv.invInvoiceDate descending select inv ;
    

    though that would pass back the objects generated by your datacontext. If you wanted to populated custom objects you could iterated over the collection creating your custom Invoice objects and populating them.

    foreach(var inv in query) { somelist.Add(new MyCustomInvoince() { id = inv.id ... }
    

    EDIT: The above will return a list. Use the following to return IQueryable

    return from item in query
        select GetInvoice(item);
    

    The difference is at this stage your are using Linq2Objects, and that provider will know how to call GetInvoice

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

Sidebar

Related Questions

I have a problem with a little .Net web application which uses the Amazon
I have problem with following query: SELECT g_contac.contid, g_contac.name, g_contac.email, f_sync.foreign_key, ( SELECT COUNT(g_cpers.cpersid)
I have problem in some JavaScript that I am writing where the Switch statement
I have problem with return statment >.< I want to store all magazine names
I have problem with starting processes in impersonated context in ASP.NET 2.0. I am
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
I have problem with ActionLink. I'd like to pass to my ActionLink parameter for
I have problem when I try insert some data to Informix TEXT column via
I do not have problem as such but I am quite new to Ruby.
I have a problem using the Java search function in Eclipse on a particular

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.