Linq Compare
-
Hi people, I would like to know of a way to compare existing users in the database while adding new ones. If user already exists then alert the user...if not add new user. I hope this makes sense, Thanks,
-
Hi people, I would like to know of a way to compare existing users in the database while adding new ones. If user already exists then alert the user...if not add new user. I hope this makes sense, Thanks,
This isn't a Linq question. Query the database before adding the user or have the insert stored proc check. What is difficult about that?
I know the language. I've read a book. - _Madmatt
-
Hi people, I would like to know of a way to compare existing users in the database while adding new ones. If user already exists then alert the user...if not add new user. I hope this makes sense, Thanks,
This should work:
var objUser = (from user in userList
where user.UserName = newUser.UserName
select user
)Although, you should consider the number of users in your database as well. There is no point in getting 10000 or likewise records just for validation. IMO a trip to database server would cost less than this.
"No matter how many fish in the sea; it will be so empty without me." - From song "Without me" by Eminem