与此answer类似,我有一个包含Proudct和LanguageAttribute的匿名对象。然后我需要像这样更新Proudct对象的属性:
function [ vol1R ] = resampling(vol1, vol2, T)
[size1, size2, size3] = size(vol2);
vol1R = zeros(size1,size2,size3); % Initializing registered vol1
for i= 1:size1
for j= 1:size2
for k = 1:size3
V = [i;j;k;1]; % V is the coordinates of a voxel on the registered vol1
% correspoding to voxel v on the vol1
% V = T * v : Relationship between v and V
v = T\V; % Problem occurs here!!!!!!! v has some negative values
% v (coordinates in vol1)
% continue
end
end
end
现在如何将结果对象中只有Proudct的列表返回给调用方法?
答案 0 :(得分:0)
你走了:
public IEnumerable<Product> GetProductList()
{
var query = from p in db.Products
join la in db.LanguageAttribute on p.ID equals la.ID
where l.LanguageID == "en-US"
select new { Product = p, Description = la.Description };
var result = query.ToList();
result.ForEach(i => i.Product.Description = i.Description);
List<Product> products = result.Select(i => i.Product).ToList();
return products;
}
List没有实现IQueryable,所以我也改变了方法的返回类型。如果仍然需要IQueryable,则可以再次使用查询。