an ASP.NET Open Source CMS & eCommerce platform
Search:
Last Post 1/26/2009 4:39:28 PM By lukezy. 1 replies.
1/26/2009 4:02:49 PM
quarterhorses
Posts: 27
Joined: 8/23/2008
Linq question
I am not a master at Linq, but I am learning. I want to change this statement so if av.PriceAdjustment is zero. The just show av.Value.
 
When av.PriceAdjustment is greater than zero do this:

                    ddl.DataSource = from av in attrib.GetAvailableValues(showOutofStock)
                        select new
                        {
                              DisplayValue = string.Format("{0} ${1}", av.Value, av.PriceAdjustment),
                              ProductAttributeValueId = av.ProductAttributeValueId,
                        };
 

 
When av.PriceAdjustment is zero do this:

                    ddl.DataSource = from av in attrib.GetAvailableValues(showOutofStock)
                        select new
                        {
                              DisplayValue = string.Format("{0}", av.Value),
                              ProductAttributeValueId = av.ProductAttributeValueId,
                        };
 

),

 

 

1/26/2009 4:39:28 PM
lukezy
Posts: 2109
Joined: 6/12/2007
Location:WA, US
Re: Linq question
ddl.DataSource = from av in attrib.GetAvailableValues(showOutofStock)
                        select new
                        {
                              DisplayValue = string.Format("{0}{1}", av.Value, string.Format("${0}", av.PriceAdjustment > 0 ? av.PriceAdjustment : "")),
                              ProductAttributeValueId = av.ProductAttributeValueId,
                        };
DotShoppingCart Staff