按名称搜索并获得ID的名称 [英] searching by name and get ID for the name

查看:153
本文介绍了按名称搜索并获得ID的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道PHP代码:

从客户那里选择id,其中customer.name ="salma"

如何在MVC中转换此代码.

这意味着我想通过在MVC中搜索来获取特定名称的ID.

我需要你的帮助.

I know the PHP code :

select id from customer where customer.name="salma"

how can I convert this code in MVC.

that means I want to get id for specific name by searching in MVC.

I need your help. please be ahead to help.

推荐答案

您可以使用相同的查询,或者如果您正在使用Entity Framework,则可以使用LINQ查询Like

You can use same query or If You are using Entity Framework then use LINQ query Like

var result = (from c in DbContext.customer
             where c.name == "salma"
             select c).FirstOrDefault();


这篇关于按名称搜索并获得ID的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆