Linq to Sql Projection Help

Posted by Micah on Stack Overflow See other posts from Stack Overflow or by Micah
Published on 2010-06-09T19:42:29Z Indexed on 2010/06/09 19:52 UTC
Read the original article Hit count: 352

Filed under:
|
|

I've reached the end of my Linq rope. Need your help!

Heres my table structure first(all linq to sql objects):

InventoryItems
  -ID
  -AmtInStock

IventoryKits
  -ID

InventoryKits_to_InventoryItems
  -InventoryItemID
  -InventoryKitID

So i need to do a projection like the following

 var q2=from k in GetAllKits()//returns IQueryable<InventoryKit>
                    select new VMPublication()//ViewModel Object
                   {
                       ID = k.ID,
                       Name = k.Name,
                       WebAmountInStock = ,//need to get the Min() AmtInStock from InventoryItems here
                       ItemCode = k.ItemCode,
                       WebAmountOrdered = k.AmtOrdered.ToString(),
                       WebReminderAmount = "",
                       WebAmountWarning="",
                       Type = "Kit"
                   };

i have no idea how to get that Min() of InventoryItem's AmtInStock in that query.

Please help! Very Appreciated!

© Stack Overflow or respective owner

Related posts about LINQ

Related posts about linq-to-sql