Linq to Sql with Sql server 2005 xml fields [英] Linq to Sql with Sql server 2005 xml fields
本文介绍了Linq to Sql with Sql server 2005 xml fields的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好我有一个包含多个xml字段的表 我应该如何从表中一次获取多条记录使用linq查询 如果你们有任何想法..请帮助我....
解决方案
假设您有一个名为"MyXmlData"的表格。看起来像这样:
create table MyXmlData(MyXmlDataID int identity primary key,SomeXmlData xml not null)
...你的DataContext被称为"MyDataContext"。
>将Linq-to-Sql类添加到应用程序并添加表后,您可以创建一个类似的部分类(注意*部分类必须与Linq-to-Sql对象位于相同的命名空间中):
public partial class MyXmlData { public IList< MyXmlData> GetAll() { < td> 使用 ( MyDataContext DC = new MyDataContext ()) { return (来自x DC.GetTable< MyXmlData>() 选择x).ToList(); } } }
Hi I have a table with more than one xml field
How should i get multiple records from the table at a time using linq query
If u guys have any idea ..Please help me....
解决方案Lets say you have a table called "MyXmlData" that looks like so:
create table MyXmlData(MyXmlDataID int identity primary key, SomeXmlData xml not null)
...and your DataContext is called "MyDataContext".
After adding the Linq-to-Sql class to your application and adding the table, you could then create a partial class like so (Note* the partial class must be located in the same namespace as the Linq-to-Sql object):
public partial class MyXmlData { public IList<MyXmlData> GetAll() { using (MyDataContext DC = new MyDataContext()) { return (from x in DC.GetTable<MyXmlData>() select x).ToList(); } } }
这篇关于Linq to Sql with Sql server 2005 xml fields的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文