LINQ Query to join db table with list of Id/Date parameters RRS feed

  • Question

  • I have a db table on which two columns are Id and WorkDate.  I am using RIA Services and I somehow need to pass pairs of Id's/WorkDates to my query method, and in that method join my table with the pairings of parameters to obtain the result.  In sql it is a simple enough query with some sort of temp table or table-valued parms containing the parameters, i.e.:

    select t.*

    from table1 t

         inner join #parms p on = and p.WorkDate = t.WorkDate

    How do I convert this into LINQ?  Thanks in advance for any assistance.

    Monday, October 15, 2012 3:22 PM


  • If you want to perform inner join operation of database tables in LINQ, I do not suggest to do it, cause you better do your inner joins in SQL Table Valued function and get the result in LINQ.

    If you are working with disconnected objects. So here is the sample:

    from t1 in db.Table1
    join t2 in db.Table2 on t1.field equals t2.field
    select new { t1.field2, t2.field3}

    Please mark as reply if helped.
    Also visit my blog

    Tuesday, October 16, 2012 10:26 AM