Results 1 to 35 of 35

Thread: [RESOLVED] linq statement that returns a count

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2008
    Location
    Burlington, ON, Canada
    Posts
    343

    Resolved [RESOLVED] linq statement that returns a count

    hi all,

    i have a linq statement that returns a resultset from a domainservice - what i'm really after is the number of records, not the records themselves and for the life of me cannot get it....code is below and any help would be appreciated:

    The table is called login and is associated with its entity dataset called logins - the project is called EstimatorSilverlight

    Code:
    Public Function GetLoginsByName(ByVal username As String, ByVal password As String) As IQueryable(Of login)
            Dim count As Integer = Me.ObjectContext.logins.Where(Function(t) t.username = username AndAlso t.password = password).AsQueryable().Count()
            Return count
        End Function

    The error is "Value of type 'Integer' cannot be converted to 'System.Linq.IQueryable(Of EstimatorSilverlight.Web.login)'.


    the original code that successfully returns the resultset is here:

    Code:
    Return Me.ObjectContext.logins.Where(Function(t) t.username = username AndAlso t.password = password)
    Last edited by trevorjeaton; Jul 7th, 2010 at 07:40 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width