关于 Northwind DB 示例的问题
当弄乱 Subsonic 3.0 Northwind 的东西时:
var product = Product.SingleOrDefault(x => x.ProductID == 1);
我发现使用智能感知可以实现以下功能,但不可行:
var product = Product.SingleOrDefault(x => x.OrderDetails == 1);
OrderDetails 作为 Product 的成员,是一个 IQueryable。我想我是 LINQ 的新手,但我想知道如何使用这个成员?每次我尝试从中获取信息时都会收到错误。有人可以给我一个如何使用 Product 的 OrderDetails 成员的示例吗?也许将数据绑定中的结果扔到 Gridview 中?
查看以下代码并告诉我我做错了什么:
var products = from od in OrderDetail.All()
join p in Product.All() on od.ProductID equals p.ProductID
select od;
我收到以下错误:
Object of type 'System.Single' cannot be converted to type 'System.Decimal'.
When messing with the Subsonic 3.0 Northwind stuff:
var product = Product.SingleOrDefault(x => x.ProductID == 1);
I found the following was possible, but not workable) using intellisense:
var product = Product.SingleOrDefault(x => x.OrderDetails == 1);
OrderDetails as a member of Product, is an IQueryable. I guess I'm new to LINQ, but I was wondering how to use this member? Everytime I try to get info out of this I get an error. Could someone give me an example of how to use the OrderDetails member of Product? And perhaps throw the results in a databind to a Gridview?
Look at the following code and tell me what I'm doing wrong:
var products = from od in OrderDetail.All()
join p in Product.All() on od.ProductID equals p.ProductID
select od;
I get the following error:
Object of type 'System.Single' cannot be converted to type 'System.Decimal'.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SubSonic 公开的 IQueriable 成员是您的外键。您可以按以下方式使用它们。
The IQueriable members that are exposed by SubSonic are your Foreign Keys. You could use them in the following manner.