here class
public class cartmanage { public int prodid { get; set; } // public string prodid { get; set; } public int qty { get; set; } public string color { get; set; } public string size { get; set; } public string name { get; set; } public string shortdescription { get; set; } public string specification { get; set; } public double price { get; set; } public string skew { get; set; } public string weight { get; set; } public string maxqty { get; set; } public string productimage { get; set; } public string prd_vendor_id { get; set; } public string prddeliverydays { get; set; } public bool giftingenabled { get; set; } public int giftingid { get; set; } }
i use manage cart in website i.e list < cartmanage > prodlist_temp. when person increase quantity of item in cart. add object in list(i used increase quantity of object due functionality have implement need separate objects). did doing linq query on list , adding result cart.
var session_updating_data = prodlist_temp.where(p => p.skew == reqired_skew); prodlist_temp.add(session_updating_data.firstordefault());
the problem im having after inserting when ever change anyting in 1 of copies changes reflected in copies. example have 2 quantity of item a, i.e cart contains 2 objects containing details of item created shown above. if change giftingenabled property of 1 of objects gets reflected in both. found work around creating new object. know why weird phenomenon happening future reference.
var session_updating_data = prodlist_temp.where(p => p.skew == reqired_skew); prodlist_temp.add(session_updating_data.firstordefault());
you passing reference object list, change in object reflected everywhere. when create new object, it's separate instance.
Comments
Post a Comment