3.0/LINQ [RESOLVED] Help translate SQL to LINQ-VBForums
Results 1 to 2 of 2

Thread: [RESOLVED] Help translate SQL to LINQ

  1. #1

    Thread Starter
    Frenzied Member Zakary's Avatar
    Join Date
    Mar 2005
    Location
    Canada, Quebec, Montreal
    Posts
    1,654

    Resolved [RESOLVED] Help translate SQL to LINQ

    Hi! any one can help me translate this SQL to LINQ to SQL?
    Especially with the CASE WHEN statement.

    DECLARE @Language INT
    SET @Language = 1

    SELECT
    tblSites.ID,
    tblSites.Code + ' ' + tblSites.NoCivic + ', ' + CASE WHEN @Language = 1 THEN DV.DescrFr ELSE DV.DescrEn END AS Street
    FROM
    tblSites
    LEFT JOIN tblDomval AS DV ON tblSites.pProvinceID = DV.ID
    Using VS 2010 on Fw4.0

  2. #2

    Thread Starter
    Frenzied Member Zakary's Avatar
    Join Date
    Mar 2005
    Location
    Canada, Quebec, Montreal
    Posts
    1,654

    Re: Help translate SQL to LINQ

    Hi think I have found;
    Code:
      var lSite = from dta in gmr.tblSites
                            join dv in gmr.tblDomVals on dta.pProvinceID equals dv.ID into dvprov
                            from dvProv in dvprov.DefaultIfEmpty()
                            where dta.EstDepot == (pSiteType == Enums.Enums.eTypeSite.Depot) && dta.Actif == true
                            select new
                            {
                                dta.ID,
                                Valeur = dta.Code ?? string.Empty
                                 + " " + dta.NoCivic ?? string.Empty
                                 + ", " + dta.Rue ?? string.Empty
                                 + " " + (GMR.Language.Translate.CurrentLanguage == Enums.Enums.eLanguage.Francais ?  dvProv.DescrFr
                                           : GMR.Language.Translate.CurrentLanguage == Enums.Enums.eLanguage.Anglais ? dvProv.DescrEn 
                                           : dvProv.DescrFr)
                                 + " " + dta.CodePostal ?? string.Empty
                            };
    Using VS 2010 on Fw4.0

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.