none
LINQ to entities - How do i get a simple table count RRS feed

  • Question

  • I'm a complete newbie to LINQ to entities . . . 

    How do i get a simple table count and show it as a label on a web page. what am I doing wrong here?

    Using entities As New Entities

    Dim itemcount= (From i In entities.tblItems

    Select ICount = i.ItemID.Count())

    lblItemCount.Text = itemcount("ICount").ToString

    end using

    Thursday, October 13, 2011 3:49 PM

Answers

  • On 10/13/2011 11:49 AM, Hugh Jarmze wrote:
    > I'm a complete newbie to LINQ to entities . . .
    >
    > How do i get a simple table count and show it as a label on a web page.
    > what am I doing wrong here?
    >
    > Using entities As New Entities
    >
    > Dim itemcount= (From i In entities.tblItems
    >
    > Select ICount = i.ItemID.Count())
    >
    > lblItemCount.Text = itemcount("ICount").ToString
    >
    > end using
    >
     
    Dim itemcount= (From i In entities.tblItems
     
    Select a).Count();
     
    label.text = itemcount.Tostring
     
    Thursday, October 13, 2011 5:03 PM
  • Hi Hugh;

    Just one small correction to darnold924 post the a in the select clause should be i as shown below.
     
    Dim itemcount = (From i In entities.tblItems
                     Select i).Count(); 
     
    
     

    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Thursday, October 13, 2011 6:20 PM

All replies

  • On 10/13/2011 11:49 AM, Hugh Jarmze wrote:
    > I'm a complete newbie to LINQ to entities . . .
    >
    > How do i get a simple table count and show it as a label on a web page.
    > what am I doing wrong here?
    >
    > Using entities As New Entities
    >
    > Dim itemcount= (From i In entities.tblItems
    >
    > Select ICount = i.ItemID.Count())
    >
    > lblItemCount.Text = itemcount("ICount").ToString
    >
    > end using
    >
     
    Dim itemcount= (From i In entities.tblItems
     
    Select a).Count();
     
    label.text = itemcount.Tostring
     
    Thursday, October 13, 2011 5:03 PM
  • Hi Hugh;

    Just one small correction to darnold924 post the a in the select clause should be i as shown below.
     
    Dim itemcount = (From i In entities.tblItems
                     Select i).Count(); 
     
    
     

    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Thursday, October 13, 2011 6:20 PM