select new { s.width, s.height, s.number}
がSystem.Linq.IQueryable<AnonymousType#1>
を意味しますが、あなたの関数がIQueryable<Product>
を返すように想定しているため。 UPDATED
public IQueryable<Product> ListProducts(string prodcutType)
{
var results = from p in db.Products
join s in db.Stocks
on p.ID equals s.IDProduct
where p.ptype == prodcutType
select p;
return results;
}
:
をそれともIQueryable<Stock>
をしたい:にあなたのコードを変更し
public IQueryable<Stock> ListProducts(string prodcutType)
{
var results = from p in db.Products
join s in db.Stocks
on p.ID equals s.IDProduct
where p.ptype == prodcutType
select s;
return results;
}
あなただけの3つのプロパティをしたい場合は、+高さ+数が新しいタイプを作成幅。たとえば、次のように
public class SomeType {
public int Width { get; set; }
public int Height { get; set; }
public int Number { get; set; }
}
public IQueryable<SomeType> ListProducts(string prodcutType)
{
var results = from p in db.Products
join s in db.Stocks
on p.ID equals s.IDProduct
where p.ptype == prodcutType
select new SomeType {
Width = s.width,
Height = s.height,
Number = s.number
};
return results;
}