sql server - EF 6 Raw SQL Queries null value -


i try fetch data db , bind internal class object field null should have data.

here internal class

    internal class query1     {         public decimal? workedhours {get;set;}         public decimal? woff { get; set; }         public decimal? abilact { get; set; }         public decimal? abilori { get; set; }         public decimal? rratio { get; set; }         public decimal? frec { get; set; }     } 

here query

 var ttk = new sqlparameter("@ttk", element.tkinit);  var year = new sqlparameter("@year",start.substring(1,3));  var ed = new sqlparameter("@end",end);  var st = new sqlparameter("@start",start);      string sqlquery = @"select      sum(inq.thhrwkdw) workedhours,     sum(inq.thcrdc) woff,     sum(inq.thdobidb) abilact,     sum(inq.thdowkdb) abilori,     ((sum(inq.thdobidb)-sum(inq.thdowkdb))/(sum(inq.thdowkdb)+1) * 100) + 100 rratio,     sum(inq.thdocodc) frec     dbo.inqtimewahs inq     inner join dbo.timekeep tk on tk.tkinit = inq.ivalue     inq.ivalue = '@ttk'and inq.iper in  (select iper inqtimewahs iper '%@year' , iper >= '@start' , iper <= '@end') , tk.tktmdate null";     resultq1 = econtext.database.sqlquery<query1>(sqlquery, ttk, year, st, ed).singleordefault(); 

did miss because have query more simple 1 , fetch data other table. same query using in application without binding , parameter work in old app.

you don't need put quotes around parameters:

select iper inqtimewahs iper '%' + @year , iper >= @start , iper <= @end 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -