How to execute sql statement in asp.net mvc3 (C#)? I am using Entity Data Model for my asp.net mvc application
I need to execute a sql query (“select * from users where EmailAddress like '%@gmail.com'“).
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Is your
Userentity mapped? In such case yo can useIf you don’t have
Usertable mapped but you haveUserclass with parameterless constructor and public settable properties with same names as columns in result set you can use:in case of ObjectContext API or:
If you don’t have entity you can execute it as any other ADO.NET command by creating
SqlConnection,SqlCommandand callingExecuteReaderon the command.