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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:50:06+00:00 2026-05-31T15:50:06+00:00

I am working on a project where we need to create complex queries against

  • 0

I am working on a project where we need to create complex queries against
a WCF service.

The service uses linq to sql at the backend and projects queries to data transfer objects like this:


    dbContext.GetQueryable()
                  .Where(x => x.Id == formatId)
                    .Select(x => FormatHelper.PopulateMSFormat(x))
                    .ToList();

What I want to do is to specify a query on the client side, lets say i want to query all formats having a certain property or a couple of them.
Something in the style of this:


     var assets = client.QueryForAssets().Where(x => (x.name == "Test" || x == "Arne") && x.doe ==  "john");

Iam aware that I can’t return IQueryable over WCF but that something like that can be done with OData services. The problem is that I have to return the DTO’s and OData let me quite easily bind to L2S-datacontext which exposes my data model and not the DTO’s.

So is there a good way of serializing a query against the DTO that efficiently will propagate to the l2s layer?

I thought about writing my own query language, but I found out that it would be quite hard to build the correct expression tree as a predicate to l2s as there is no mapping from the DTO to the linq classes.

  • 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-31T15:50:08+00:00Added an answer on May 31, 2026 at 3:50 pm

    With OData services, you are not bound to return database entities directly. You can simply return any DTO in queryable format. Then with the help of LINQ’s Select() method, you can simply convert any database entity into DTO just before serving the query:

    public class DataModel
    {
      public DataModel()
      {
        using (var dbContext = new DatabaseContext())
        {
          Employees = from e in dbContext.Employee
                      select new EmployeeDto
                      {
                        ID = e.EmployeeID,
                        DepartmentID = e.DepartmentID,
                        AddressID = e.AddressID,
                        FirstName = e.FirstName,
                        LastName = e.LastName,
                        StreetNumber = e.Address.StreetNumber,
                        StreetName = e.Address.StreetName
                      };
        }
      }
    
      /// <summary>Returns the list of employees.</summary>
      public IQueryable<EmployeeDto> Employees { get; private set; }
    }
    

    You can now easily set this up as a OData service like this:

    public class EmployeeDataService : DataService<DataModel>
    

    For full implementation details, see this excellent article on the subject. OData services are actually very very powerful once you get the hand of them.

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

Sidebar

Related Questions

I'm working on a project where I need the following. WCF service on the
I am working on a project where I need to create a boundary around
I'm working on a database project and I need to create Outlook 2007 plugin
In a PHP project I'm working on we need to create some DAL extensions
In a project I'm working on in C++, I need to create objects for
I'm working on a project and I need to create an API. I am
I'm working on SS7 project and reached a point where I need to create
I am currently working on a project in java. I need to create a
I am working on android applications. In my project I need to create Listview.
I need to create a div carousel for a project Im working on. I

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.