c# - Asp.net equivivalent to Model.objects.get(name=Somebody) in django -


i have user table , has username field. how do in asp.net:

user = user.objects.get(username="somebody") 

i.e. user username.

i don't want use raw sql query. how data?

considering user.objects return implementation of ienumerable<user> you, use linq username property, sample:

add namespace use linq:

using system.linq; 

and try this:

// in case, considering user collection var user = user.first(x => x.username == "somebody"); 

if using entity framework, try using context:

var user = context.dbset<user>().first(x => x.username == "somebody"); 

see more samples linq here in 101-linq-samples


Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -