Question sur les requêtes SQL
Bonjour,
Pour le développement de mon appli, j'aurais besoin d'un renseignement, comment utiliser ce genre de requête avec MVC3 :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
select
CD_CR,
LB_CR,
CD_APPLI,
LB_APPLI,
case
when (CD_APPLI = 'ESPAS' and exists (select 1 from dbo.LOGS l where l.PERIODE =(select MAX(PERIODE) from dbo.LOGS) and l.STATUT = 'KO'))
then 'KO'
when (CD_APPLI = 'ESPAS' and not exists (select 1 from dbo.LOGS l where l.PERIODE =(select MAX(PERIODE) from dbo.LOGS) and l.STATUT in('KO','NEXEC')))
then 'OK'
when CD_APPLI = 'ESPAS' and (not exists (select 1 from dbo.LOGS l where l.PERIODE =(select MAX(PERIODE) from dbo.LOGS) and l.STATUT ='KO'))
and (exists (select 1 from dbo.LOGS l where l.PERIODE =(select MAX(PERIODE) from dbo.LOGS) and l.STATUT ='NEXEC'))
then 'EN COURS'
else NULL
end STATUT
from
dbo.REF_CR,
dbo.REF_APPLI
order by CD_CR,ORDRE_APPLI |
Cette requête sera surement réutilisée dans mon code mais le truc, c'est que j'étais habitué aux requêtes du type :
Code:
1 2 3
|
var query = (from a in db.Appli
select new Applis { CR = a.CR, ESPAS = (int)a.ESPAS, BO = (int)a.BO, PNB = (int)a.PNB }).ToList(); |
Je me demande donc comment transformer la première pour pouvoir l'utiliser avec ASP.NET MVC3 de la même façon que la deuxième.
Le plus gros problème c'est le switch avec les :
Code:
1 2
| when (CD_APPLI = 'ESPAS' and exists (select 1 from dbo.LOGS l where l.PERIODE =(select MAX(PERIODE) from dbo.LOGS) and l.STATUT = 'KO'))
then 'KO' |
Je ne vois pas comment faire un switch dans mes requêtes...
Est-ce que c'est possible ? 8O
Merci d'avance pour vos réponses.
PS : Désolé de poster autant de sujets :?