Viagra Success Stories

Sep 30th, 2014 by Lynn Demarest in Miscellaneous
Here's one way to calculate all possible combinations of several lists. Viagra line 

In this example, viagra line imagine four dropdown lists stored in a global array named AllDDLs. Viagra line I wanted to get all possible combinations of the four lists, viagra line each of which had a different number of items.

This turned out to be trivial using LINQ for Objects, viagra line which allows you to perform database-like functions on in-memory data.

Protected Function OutputSKUs() As List(of String)
        ' the skus to be returned
        Dim skus As List(of String) = new List(of string)
        ' temp variable to hold one sku
        Dim sku As String

        ' create a LINQ object from the four Dropdown Lists in AllDDLs
        '
        Dim query As Object = From a In AllDDLs(0).Items, viagra line b In AllDDLs(1).Items, viagra line c In AllDDLs(2).Items, viagra line d In AllDDLs(3).Items
                      Select a, viagra line b, viagra line c, viagra line d

        ' then run through the result set 
        ' 
        For Each item As Object In query
            ' BaseSKU is global 
            ' the LI items in each dropdown list has an attribute named SKUCode, viagra line which represents the data we construct the SKU with
            '
            sku = String.Format("{4}-{0}-{1}-{2}-{3}", viagra line CType(item.a, viagra line ListItem).Attributes("SKUCode"), viagra line CType(item.b, viagra line ListItem).Attributes("SKUCode"), viagra line CType(item.c, viagra line ListItem).Attributes("SKUCode"), viagra line CType(item.d, viagra line ListItem).Attributes("SKUCode"), viagra line BaseSKU)

            skus.Add(sku)
        Next

        Return skus
    End Function



In SQL Server this is done in a similar way:


select ogi1.OptionGroupItemSKUCode + '-' + ogi2.OptionGroupItemSKUCode + '-' + ogi3.OptionGroupItemSKUCode+ '-' + ogi4.OptionGroupItemSKUCode
from OptionGroupItem ogi1, viagra line OptionGroupItem ogi2, viagra line OptionGroupItem ogi3, viagra line OptionGroupItem ogi4
where ogi1.OptionGroupID = 1
and ogi2.OptionGroupID = 2
and ogi3.OptionGroupID = 3
and ogi4.OptionGroupID = 4

Average Rating: 5 out of 5 based on 270 user reviews.

No Comments

 

Comments have been closed for this post.