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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:38:02+00:00 2026-05-23T11:38:02+00:00

in the domain service class there are two entities which I would like to

  • 0

in the domain service class there are two entities which I would like to use in join query: WorkerOnMachine {id(int), WorkerId(int), MachineId(int)} and Worker(WorkerId(int), Name(string)…)

I wanted to create a method in domain service class which returned all workers that operate on selected machine (the worker-machine relationships are stored in WorkerOnMachineTable) the following way:

public IQueryable<Worker> GetWorkerByMachineId(int machineId)
        {
            var joinedTable = from wom in this.ObjectContext.WorkerOnMachine
                              join w in this.ObjectContext.Worker on wom.WorkerId equals w.Id
                              where wom.MachineId == machineId
                              select new { w };
            return joinedTable as IQueryable<Worker>;
        }

but the method returns an empty list. Does anyone know what is the right way to write the above method in domain service class?

Thank you!

  • 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-23T11:38:03+00:00Added an answer on May 23, 2026 at 11:38 am

    Don’t use var, it is confusing you.

    As written, joinedTables is an instance of IQueryable<AnonType>. Since it is not an IQueryable<Worker> the cast by as returns null.

    Instead, write:

    IQueryable<Worker> joinedTable = ...
    

    Then fix:

    select w;
    

    and finally:

    return joinedTable;
    

    (btw, that join looks good).

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

Sidebar

Related Questions

What I would like to do is have a common Service class which has
After adding a domain service class, there are no datacontext classes for me to
Been doing some playing call my service which is on a different domain using
Im trying to create a web service which gets to a URL e.g. www.domain.co.uk/prices.csv
I have a structure with the following domain classes: class Service{ static hasMany=[serviceRequirements:ServiceRequirement]} And
I am trying to create a query in my domain service (VS 2010 Silverlight
I'm extending a partial class that was generated from an Entity Framework domain service
We have an application with a plugin which contains a service: public class TaskService
In a RIA Domain service I have added some utility functions. For instance we
How can I invoke a service directly from a view? I'm trying with ${my.domain.service.method}

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.