-1

Hi I currently have a Collection container and I need to dump its contents into an ArrayList or a List. This ArrayList holds a dictionary object.

Now if I have something like this I tried doing ToList but it doesnt work

Collection<object> content = new Collection<object>();
....populate content container.....
List <Dictionary<string, string>> lst = new List <Dictionary<string, string>>();
lst= ( List< Dictionary<string, string> > ) content.ToList();

Any suggestions on how I could do this ?

Edit: My content collection should be a list which contains a map.


Combining multiple column values into a single column row result

I have a query that pulls in group sale orders for a venue. My current query pulls all of the info I need, but gives me multiple rows for each order number:

ordCode cltClientName          adrCityDesc  adrStateDesc    adrZipCode  gsnValue2   evShow  shDescr
739802  Stevens Elementary,    Aberdeen         WA             98520       64        183    Group - Museum Admission
739802  Stevens Elementary,    Aberdeen         WA             98520       64        237    Extreme Planets

What I would like to see is a single row for each order, but with the last column having results separated by comma:

ordCode cltClientName          adrCityDesc  adrStateDesc    adrZipCode  gsnValue2   evShow  shDescr
739802  Stevens Elementary,    Aberdeen         WA             98520       64        183    Group - Museum Admission, Extreme Planets

The Query:

SELECT DISTINCT(ordCode),
        cltClientName, 
        adrCityDesc,
        adrStateDesc,
        adrZipCode,
        gsnValue2,
        evShow,
        shDescr

--COUNT(tiCode)
  from Orders 
        inner join OrderContacts on orcOrderNumber = ordCode
        inner join Clients on orcClientID = cltCode
        inner join ClientAddresses on cltCode = claClientCode
        inner join Addresses on claAddressCode = adrCode
        inner join Tickets on tiOrder = ordCode
        inner join dbo.Events on tiEvent = evCode
        inner join GroupSaleNotes on ordCode = gsnOrderNumber
        inner join Shows on evShow = shCode
 WHERE ordOrderTypeTitle = 7 -- Group Sales only
  and ordOpenDate between '2011-06-01 00:00:00.000' and '2012-05-31 23:59:59.999'
  and gsnNoteType = '5'
  and cltIsGroupLeader = '1'
   --and evShow in (106, 107)
 GROUP BY ordCode, cltClientName, cltCode, adrCityDesc, adrStateDesc,
      adrZipCode, gsnValue2, evShow, shDescr
ORDER BY adrCityDesc, cltClientName

Is there a way to combine this part of the result set?

4

1 回答 1

4

如果您愿意,可以将其转换为 Dictionary,但您必须确保执行运行时检查...

lst = content.Cast<Dictionary<string, string>>().ToList();
于 2012-10-22T22:05:43.660 回答