Friday, March 8, 2019

Need help with linq query

I have this linq query

from furn in Furnitures where furn.FurnitureId == 9 join furnImage in FurnitureImages on furn.FurnitureId equals furnImage.FurnitureId into imageGroup select new { FurnitureId = furn.FurnitureId, Name = furn.Name, UID = furn.UID, CategoryId = furn.CategoryId, Cost = furn.Cost, PurchasedFrom = furn.PurchasedFrom, DatePurchased = furn.DatePurchased, HouseId = furn.HouseId, Turns = furn.Turns, FurnitureImages = imageGroup.ToList() } 

I used LinqPad to get this working to where it returns a record from Furniture table and it's associate Furniture image from the FurnitureImage table.

My problem is that the API repository needs to return an IEnumerable suggesting that it will be a list. I would like it to only need to return one record, as there will be only one record associated with a FurnitureId. I see that the first part of query is returning 'IQueryable<Anonymous>' from the Furniture table.

https://i.redd.it/iu92mccce0l21.png

How can I get it to just return 'Furniture'?

Need help with linq query Click here
  • Blogger Comment
  • Facebook Comment

0 comments:

Post a Comment

The webdev Team