Link to home
Start Free TrialLog in
Avatar of JRockFL
JRockFLFlag for United States of America

asked on

Linq and List

Does this look correct? I'm not getting any compiler errors, but I wanted a second set of eyes to look at it.

Is there another way of doing this without the CType ?

 
Public Shared Function GetTop5ThisMonth() As List(Of Entities.PromoCodeUsuage)
            Dim startDate As New DateTime(Date.Now.Year, Date.Now.Month, 1)
            Dim endDate As DateTime = startDate.AddMonths(1)
            Dim list As List(Of Entities.PromoCodeUsuage) = BusinessObjects.PromoCodeUsuage.List(startDate, endDate)

            Return CType((From l In list Order By l.Total Descending Select l).Take(5), List(Of Entities.PromoCodeUsuage))
        End Function

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Imran Javed Zia
Imran Javed Zia
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JRockFL

ASKER

Ok great, thank you!
You are Most Welcome