Answered Ling to SQL Sum Syntax

  • Sunday, December 30, 2012 6:26 AM
     
      Has Code
    I am trying to convert the SQL Query 
    Select Hours_Actual
    From cwwebapp_infinitynetworks.dbo.Time_Entry
    Where Company_RecID = 1247
    To linq for VB.  What I have is this: 
            Dim linqtest = (Aggregate Time_Entry In Cwwebapp_infinitynetworksDataSet.Time_Entry _
                            Where Time_Entry.Company_RecID = 1247 _
                            Into Sum(Time_Entry.Hours_Actual))
    The SQL returns a result of 11.64 but lingtest returns 0D.  I am at a loss to at what is wrong.

All Replies

  • Sunday, December 30, 2012 2:55 PM
     
     Answered Has Code

    Hi Shadow Night;

    Try this query.

    Dim linqtest = (From te in ObjectContextName.Time_Entry _
                    Where te.Company_RecID = 1247 _
                    Select te.Hours_Actual).Sum()

      


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".