如何使用Linq查询从数据库中的给定名称中选择id。 [英] how to pick id from given name in database using Linq query.
问题描述
先生,
我想从数据库中使用Linq查询中的给定名称中获取ID。
描述:
这里我在excel表中键入Country,State name。对于批量上传,我想在数据库中存储ID,并在网格索引中显示名称。在这里,我想使用Linq查询为此。我正在使用MVC 5存储库模式。
请帮助我完成这项任务。
< blockquote>这个解决方案是你的问题的预期: -
var id = Context。 NAME .Where(x = > x.Name == name).Select(x = > x.ID);
将名称作为参数传递给功能。希望名字是唯一的。
谢谢
:)
hi sir,
I want to pick up ID from Given name in database Using Linq query.
DESCRIPTION:
Here i type Country ,State name in excel sheet.For bulk upload, i want to store ID in database and name shown in grid index. Here i want to using Linq query For this.And i'm using MVC 5 Repository pattern.
Kindly help me for this task.
This solution is an anticipation from your question:-
var id = Context."NAME".Where(x => x.Name == name).Select(x => x.ID);
Pass the name as parameter to the fuction. Hoping name is unique.
Thanks
:)
这篇关于如何使用Linq查询从数据库中的给定名称中选择id。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!