Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9116339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:38:56+00:00 2026-06-17T04:38:56+00:00

I am migrating some code from ColdFusion to .NET LinqToSQL. The following query is

  • 0

I am migrating some code from ColdFusion to .NET LinqToSQL. The following query is currently embedded into ColdFusion. Rather than trying to get LinqToSQL to this, I am considering writing a stored procedure. Note: the ## in CF in this context is really a # in SQL. I am not creating a global temp table

<cfquery name="qryTrafficDetails">
    DECLARE @startDate date
    DECLARE @endDate date
    SET     @startDate = <cfqueryparam cfsqltype="CF_SQL_date" value="#filter.StartDate#">
    SET     @endDate = <cfqueryparam cfsqltype="CF_SQL_date" value="#filter.endDate#">


    SELECT  CONVERT(date, CreateDate) AS CreateDate, url_vars.value('(search)[1]', 'nvarchar(max)') AS Item, remote_addr
    INTO    ##tempTraffic
    FROM    dbo.Traffic WITH (NOLOCK)

    WHERE   Createdate BETWEEN @startDate AND @endDate
    AND     url_vars.exist('.[search]') = 1     


    SELECT Area, AreaSort, Item, CalendarDate, isNull(Visitor, 0) AS Visitor, ISNULL(Hit,0) AS Hit
    FROM    dbo.Calendar LEFT JOIN 
        (



        SELECT AreaSort = 10, 'Search' AS Area, FullGrid.Item AS Item, FullGrid.CalendarDate AS CreateDate,

                COUNT(DISTINCT remote_addr) AS visitor, 
                COUNT(remote_addr) as hit

        FROM  (
            SELECT DISTINCT CalendarDate, Item
            FROM dbo.Calendar, ##TempTraffic
            WHERE   CalendarDate  BETWEEN @startDate AND @endDate
            ) FullGrid 

        LEFT JOIN ##TempTraffic AS DataItem
            ON FullGrid.CalendarDate = CreateDate
            AND FullGrid.Item = DataItem.Item       

        GROUP BY FullGrid.Item, FullGrid.CalendarDate



        ) AS SummaryDetail

    ON  CalendarDate = SummaryDetail.CreateDate

    WHERE   CalendarDate  BETWEEN @startDate AND @endDate
    AND AreaSort IS NOT NULL    

    ORDER BY AreaSort, Item, CalendarDate
    </cfquery>

    <cfreturn qryTrafficDetails>

Some of the issues I am concerned with are:

  • How to deal with temp tables
  • Does LinqToSql cover everything?
  • Is this an example of where LinqToSql is not appropriate?
  • Performance
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:38:58+00:00Added an answer on June 17, 2026 at 4:38 am

    I’m not completely sure about the intentions and motivations of your sql code but seems to be a summary report. In this case probably linq to sql is not the ideal solution.

    I don’t think that you can create temp table from linq 2 sql. You can create sub query or maybe you can use linq 2 object to join the results of previously executed query.

    But my suggestion is to check if there isn’t a better way to query your data using a more concise query that can be executed also on linq 2 sql.

    If you really need this kind of query probably it’s better to put it in a stored procedure.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm migrating some code from VB.NET to C# (3.5). I find structures like: Public
So I am migrating some code from VB.NET to C# however it fails when
We are currently migrating our VB6 application to Net. The VB6 code uses some
I am migrating some C++ code from structures to classes. I was using structures
I am migrating some code that executes AppleScripts from NSAppleScript to NSUserAppleScriptTask so that
I am migrating some code from the older azure table storage client to the
I'm migrating some code from the ASPX view engine to Razor and I've run
I am migrating some code from Scala 2.10-M5 to Scala 2.10-M7 . I have
I'm migrating my app from Mongoose 2.6.5 to 3.1.2, and I'm running into some
I'm migrating data from an old laptop to a new laptop, including some vb.net

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.