markrendle / Simple.Data

A light-weight, dynamic data access component for C# 4.0
MIT License
1.33k stars 303 forks source link

Use SQL query #385

Open fangyukui opened 8 years ago

fangyukui commented 8 years ago

Hi ! I have a SQL statement:

SELECT Organization_ID,Organization_Name,ParentId,'0' AS isUser FROM Base_Organization UNION ALL SELECT U.User_ID AS Organization_ID ,U.User_Code+'|'+U.User_Name AS User_Name,S.Organization_ID,'1' AS isUser FROM Base_UserInfo U RIGHT JOIN Base_StaffOrganize S ON U.User_ID = S.User_ID

Could you tell me how to write using Simple.Data ? thank you !!

BenMagyar commented 8 years ago

Unions are not supported in Simple.Data, so it would be best to split it into two queries and then concat once fetched.

fangyukui commented 8 years ago

Thank you for your answers! But we still have a problem.

select a,b,c,'0' as d from [table]

'0' as d how to write using Simple.Data?

BenMagyar commented 8 years ago

Aliasing a constant value is not supported either I believe, it must be a reference to a column.

j-hudecek commented 8 years ago

you can also use Simple.Data.RawSql https://github.com/jasondentler/Simple.Data.RawSql

fangyukui commented 8 years ago

Thank!