Linq and List

JRockFL
JRockFL used Ask the Experts™
on
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

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Consultant Software Engineer - .NET Architect
Commented:
Hi,
Please try this

Return (From l In list Order By l.Total Descending Select l).Take(5).ToList()

Author

Commented:
Ok great, thank you!
Imran Javed ZiaConsultant Software Engineer - .NET Architect

Commented:
You are Most Welcome

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial