Solved

LinqToSQL, Repository, Asscociations

Posted on 2012-03-29
1
332 Views
Last Modified: 2012-08-14
I have 2 tables in my database

JobTab has fields jobid int, jobloggedbyid int, jobstate int
JobUser has fields userid int, username, userisactive bit

JobTab jobloggedbyid is a foreign key to userid on on jobusers.

using lingtosql i have added both tables to the dbml, and created the association for the foreign key.

I have IRepository interface with method
Get(ByVal predicate As Expression(Of Func(Of T, Boolean))) as IQueryable(Of T)

I have 2 concrete Repository's, JobTabRepository and JobUserRepository both implement IRepository

so in the JobTabRepository  which implements IRepository(Of JobTab)

Get(some predicate here) will return a iqueryable(of jobtab).

and JobUserRepository Get(some preditcate) will return IQueryable(of JobUser)

perfectly fine to this point....

now I want to add a method to the JobTabRepository that will return me the JobTab records from the database based on whatever criteria I pass to the predicate, but I want to show the username not the loggedbyid in my final datagrid where the results end up so in essence the result should be the JobTab with its associated JobUser, I wanted to keep the return type of the method as IQueryable(of JobTab) so it keeps the Repository nice and neat, but I cant figure out how to do it keeping the return type a IQueryable(of JobTab).

sorry if this sounds like a lame question, maybe i am just being to strict with what i return from my repository, maybe repository isn't the correct way to go for this problem and i should be looking at something like CQS, I am very new to linqtosql and its associated patterns, but any help would be very much appreciated.

Thanks
0
Comment
Question by:SniperX1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 37782853
>keeping the return type a IQueryable(of JobTab)

First thing is that if you change the properties of the result set then it will become an anonymous type not JobTab.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question