C# Writing SQL queries -


i'm trying write custom query , keep getting

sqlexception unhandled `error' - incorrect syntax near '.'

code:

var list = dbcontext.database.sqlquery<string>("select a.assetid, a.assetname, a.seg1_code, d.shortname, e.officepercentage, e.maintenancepercentage" +            "from [core].[dbo].[asset] a" +            "left outer join [core].[dbo].[assetaddress] b" +            "on a.assetid = b.assetid" +            "left outer join [core].[dbo].[address] c" +            "on b.addressid = c.addressid" +            "left outer join [core].[dbo].[statelookup] d" +            "on c.stateid = d.stateid" +            "inner join [core].[dbo].[assetpayrollmarkupoverride] e" +            "on a.assetid = e.assetid" +            "order d.shortname, a.assetname").tolist(); 

add space before/after each of string in concatenation.

 var list = dbcontext.database.sqlquery<string>(                     "select a.assetid, a.assetname, a.seg1_code, d.shortname, e.officepercentage, e.maintenancepercentage" +                     " [core].[dbo].[asset] a" +                     " left outer join [core].[dbo].[assetaddress] b" +                     " on a.assetid = b.assetid" +                     " left outer join [core].[dbo].[address] c" +                     " on b.addressid = c.addressid" +                     " left outer join [core].[dbo].[statelookup] d" +                     " on c.stateid = d.stateid" +                     " inner join [core].[dbo].[assetpayrollmarkupoverride] e" +                     " on a.assetid = e.assetid" +                     " order d.shortname, a.assetname").tolist(); 

(in above code added space before start of new string)


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -