Click here to Skip to main content
15,885,214 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
XML
public override List<AttributeDTO> GetArray(List<int> values, List<int> values1)
{
    try
    {
        using (var context = new PICEntities())
        {
            var cnt = values.Count(); List<AttributeDTO> lst = null;
            List<AttributeDTO> lst1 = new List<AttributeDTO>();
            List<long> pids = context.pic_attr_value.Select(g => g.product_id).Distinct().ToList();
            foreach (var item in pids)
            {
                AttributeDTO attr = new AttributeDTO();

                for (var i = 0; i < cnt; i++)
                {
                    var productid = item;
                    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).Select(g => g.product_id).Distinct().SingleOrDefault();
                    if (pavs!= 0)
                    {
                        var st = context.pic_product.SingleOrDefault(a => a.product_id == pavs);
                        if (st.part_number != null && st.part_description!=null)
                        {
                            attr.AttrName = st.part_number;
                            attr.temp = st.part_description;
                        }
                        if (attr != null && i == cnt - 1)
                        {
                            lst1.Add(attr);
                        }

                    }

                    //}

                }
            }
            return lst1;
        }
    }
    catch (Exception) { return new List<AttributeDTO>(); }
}
Posted
Updated 5-Jun-14 19:30pm
v2
Comments
Prasad Avunoori 6-Jun-14 1:24am    
You are supposed break the above linq queries and ask us.
sailaja12345672 6-Jun-14 1:26am    
public override List<attributedto> GetArray(List<int> values, List<int> values1)
{
try
{
using (var context = new PICEntities())
{
var cnt = values.Count(); List<attributedto> lst = null;
List<attributedto> lst1 = new List<attributedto>();
List<long> pids = context.pic_attr_value.Select(g => g.product_id).Distinct().ToList();
foreach (var item in pids)
{
AttributeDTO attr = new AttributeDTO();

for (var i = 0; i < cnt; i++)
{
var productid = item;
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).Select(g => g.product_id).Distinct().SingleOrDefault();
if (pavs!= 0)
{
var st = context.pic_product.SingleOrDefault(a => a.product_id == pavs);
if (st.part_number != null && st.part_description!=null)
{
attr.AttrName = st.part_number;
attr.temp = st.part_description;
}
if (attr != null && i == cnt - 1)
{
lst1.Add(attr);
}

}

//}

}
}
return lst1;
}
}
catch (Exception) { return new List<attributedto>(); }
}
[no name] 6-Jun-14 3:24am    
where is your problem? we are unable to understand

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900