本文介绍了如何为此编写存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
ar cnt = values.Count(); List<AttributeDTO> lst = null;
List<AttributeDTO> lst1 = new List<AttributeDTO>();
List<pic_attr_value> pids = context.pic_attr_value.GroupBy(x => x.product_id)
.Select(g => g.FirstOrDefault())
.ToList();
foreach (var item in pids)
{
for (var i = 0; i < cnt; i++)
{
var productid = item.product_id;
var att = values[i]; var attl = values1[i];
var count = context.pic_attr_value.Count(a => a.attr_id == att && a.attr_lov_id == attl && a.product_id == productid);
if (count == 0) break;
if (i == cnt - 1)
{
var pavs = context.pic_attr_value.Where(a => a.attr_id == att && a.attr_lov_id == attl && a.product_id == productid).ToList();
lst = new List<AttributeDTO>();
foreach (var pav in pavs)
{
var attr = new AttributeDTO();
var st = context.pic_product.SingleOrDefault(a => a.product_id == pav.product_id);
if (st != null) { attr.AttrName = st.part_number; attr.temp = st.part_description; }
lst.Add(attr);
}
} if (lst != null && i == cnt - 1)
{
lst1.AddRange(lst);
}
}
}
return lst1;
推荐答案
这篇关于如何为此编写存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!