tags:

views:

27

answers:

1

Can someone help convert this query to SQL. I need this in linQ and I dont have write perms to get alternative for Storedprocedure. So linQ is the only way for me now to get it used with Silverlight

SELECT ISNULL(COUNT(BGID),0)AS BGCOUNT,CASE SOURCE.PRIORITY
WHEN 1 THEN  'P1'
WHEN 2 THEN  'P2'
WHEN 3 THEN  'P3'
END AS PRIORITY FROM
(SELECT DISTINCT PRIORITY  AS PRIORITY FROM BGS WHERE PRIORITY IS NOT NULL)AS SOURCE
 LEFT OUTER JOIN BGS ON BGS.PRIORITY = SOURCE.PRIORITY AND        
       TREEPATH NOT LIKE '%Prod%' AND TREEPATH LIKE '%TMS%' AND
       TREEPATH NOT LIKE 'BG\structure\Aut\TMS%' AND STATUS = 'ACTIVE'  AND
       (ASSIGNEDTO = 'cato14' OR ASSIGNEDTO IN 
       ('useratadi','userajsudh','useramanna','useritnaga'))
GROUP BY SOURCE.PRIORITY
ORDER BY SOURCE.PRIORITY 
A: 

If you already have SQL you're happy with, you can skip translating it to linq by calling DataContext.ExecuteQuery<T>.

David B
But can i use it in silverlight?
fashai
If you could use DataContext in silverlight, you can use this method. If you couldn't use DataContext, you couldn't have written a linqtosql query anyway.
David B
so u mean to say that we can execute sql queries in Silverlight using this.. Am I correct? I was of the impression that we cant directly use sql queries to connect to DB and it has to be via wcf/linQ
fashai
No. I mean to say that a linqtosql query wouldn't have helped you anyway, since you can't use DataContext directly from the client in silverlight without full trust.
David B