none
How to Apply Oracle Query Condition in LINQ RRS feed

  • Question

  • Hi All,

    I have one query in Oracle SQL i want to convert into LinQ,

    my collection return all Columns from Table now i want to apply all where and group by condition into linq.

    assuming i have linq which has all columns , how i can format using linq.

    SELECT   CASE
                WHEN TO_CHAR (DT1, 'YYYY') < '2009'
                   THEN 'Test1 < 01/01/2009'
                ELSE CASE
                WHEN TO_CHAR (DT1, 'YYYY') >= '2009' OR IND1 = 'Y'
                   THEN 'Test2 >= 01/01/2009'
                ELSE 'Good''
             END
             END AS Grp,
             COUNT (*) AS Cnter, SUM (NVL (AMT1, 0) +  (AMT1, 0)) AS Col1,
             SUM (NVL (AMT1, 0)) AS Col2, SUM (NVL (AMT1, 0)) AS Col3
        FROM TestTable
       WHERE CD1 = 'K'
         AND DT2 = '200910'
         AND (TO_CHAR (MTRY_DT1, 'YYYY') = '2009' OR TO_CHAR (MTRY_DT1, 'YYYY') = '2009')
    GROUP BY CASE
                WHEN TO_CHAR (DT1, 'YYYY') < '2009'
                   THEN 'Test1 < 01/01/2009'
                ELSE CASE
                WHEN TO_CHAR (DT1, 'YYYY') >= '2012' OR IND1 = 'Y'
                   THEN 'Test2 >= 01/01/2009'
                ELSE 'Good'
             END
             END

    What my problem,

    I have smilear body for all 10 queries but due to Group by Condition on sepcicif column i am unable to run from linq so calling 10 times data from datatabase,

    i thought if i pass straight query into DB and do in C# all group by then my application may be faster.

    Thanks


    Ashok

    Thursday, October 18, 2012 3:39 PM

Answers

All replies