Click here to Skip to main content
15,887,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
C#
Model.DBEntities db = new Model.DBEntities();
if (db.Users.Any(q => q.UserName == txtUserName.Text && q.Password == MD5Password))
{
 Model.User User = db.Users.First(q => q.UserName == txtUserName.Text && q.Password == MD5Password);
}
Posted

No, it's not possible. Entity Framework will put your strings into Sql-Parameters in order to execute the query so the entered text can't become part of/modify the Sql-Statement itself.
 
Share this answer
 
v2
Comments
Maciej Los 26-Apr-15 16:28pm    
4! Please, read answer ;)
Sascha Lefèvre 26-Apr-15 16:58pm    
He asked specifically about "that syntax" ;-) But it's alright! I agree that I should have mentioned it anyway. Thank you, Maciej :)
Maciej Los 27-Apr-15 1:34am    
"That syntax" - it changes everything. Upvoted!
Sascha Lefèvre 27-Apr-15 5:34am    
;-)
Sascha is right in 75%, becasue SQL injection is possible even using Entity, especially when Entity SQL is used.. Linq to Entities is completlty safe about sql injection. Note, that there is few other rules you need to respect. Please see: Security Considerations (Entity Framework)[^]
 
Share this answer
 
v3
Comments
Sascha Lefèvre 26-Apr-15 16:58pm    
5 for you!
No, it's not possible, but it is also not an excuse to be lazy and not validate and sanitize your inputs anyway.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900