我有两个记录,我试图加入和分组。我现在正试图将数据投影到另一个记录中。问题是我不知道如何获得对分组属性的访问权。以下是代码:
第一次记录:
type Product = {
Id : string;
Name : string;
Description : string;
}第二项纪录:
type ProductOption = {
Id : string;
ProductId : string;
SizeId : int;
Price : decimal;
}最后纪录:
type ProductDetails = {
Product : Product;
Options : seq<ProductOption>;
}这是我的groupBy代码:
let getProductDetails =
query{
for row in productRecords do
join opt in productOptionRecords on
(row.Id = opt.ProductId)
groupBy row.Id into prod
// here is my problem, this below does not work
select {
Product = prod.Product,
Options = prod.ProductOption
}
}我在这里做错什么了。
发布于 2014-06-12 06:08:53
我相信你要找的是groupJoin-operator。下面的代码编译,我们都知道,那么它几乎肯定是正确的。)您最好检查一下。我还没有在任何实际数据上测试过。
query{
for prod in productRecords do
groupJoin opt in productOptionRecords on
(prod.Id = opt.ProductId) into prodopts
select {
Product = prod;
Options = prodopts
}
}https://stackoverflow.com/questions/24173932
复制相似问题