SQL Server 和 LINQ 查询中的 XML 数据类型

发布于 2024-10-04 15:06:13 字数 555 浏览 0 评论 0原文

我想从 SQL Server 数据库检索 XML 数据,并使用 C# 上的 LINQ 查询将其绑定到 DropDownList。

客户表中的 XML 字段:

<root>
  <clientname>andrew</clientname> --  dropdownlist text field
  <clientid>1</clientid>          -- dropdownlist value field
  <clientname>jim</clientname>
  <clientid>2</clientid>
  <clientname>john</clientname>
  <clientid>3</clientid>
  <clientname>johnson</clientname>
  <clientid>4<clientid>
</root>

您有什么想法吗?

I want to retrieve the XML data from SQL Server database and bound it to the DropDownList using LINQ query on C#.

XML field in clients table:

<root>
  <clientname>andrew</clientname> --  dropdownlist text field
  <clientid>1</clientid>          -- dropdownlist value field
  <clientname>jim</clientname>
  <clientid>2</clientid>
  <clientname>john</clientname>
  <clientid>3</clientid>
  <clientname>johnson</clientname>
  <clientid>4<clientid>
</root>

do you have any idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

豆芽 2024-10-11 15:06:13

LINQ(大概是指 LINQ-to-SQL 或 EF)当前没有对 XML 数据类型进行任何特殊处理。您需要像平常一样取回它,然后将其加载到 DOM 中并从那里进行处理。也许看看这个问题: how to load xml file into asp.net 中的下拉列表

LINQ (presumably meaning LINQ-to-SQL or EF) doesn't currently have any special treatment of the XML data-type. You'll need to fetch it back as normal, then load it into a DOM and handle from there. Perhaps looking at the question: how to load xml file into dropdownlist in asp.net

活泼老夫 2024-10-11 15:06:13

目前尚不清楚为什么将实体列表存储为一个值。
尝试标准化您的数据库模型。

It is not clear why you store list of entities as one value.
Try to normalize your DB model.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文