开发者

How to make a simple search function in linq and EF

开发者 https://www.devze.com 2023-02-18 00:00 出处:网络
I want to simply search a database for a certain string, how c开发者_如何转开发an i accomplish this using linq and EF (if using these tools for it are not practical I am open to any suggestions).I jus

I want to simply search a database for a certain string, how c开发者_如何转开发an i accomplish this using linq and EF (if using these tools for it are not practical I am open to any suggestions). I just want to take a string and search my usernames, the search should be able to handle things only parts of the username (using some sort of 'contains' function)


The basics of what you are asking is..

var found = MyContext.Users.Where(user => user.UserName.Contains(searchString));

You would need to substitute actual entity names/values for the example code posted.

0

精彩评论

暂无评论...
验证码 换一张
取 消