NorthwindDataContext db=new NorthwindDataContext();
var custs=db.Customers;
XElement xelement = new XElement("Customers",
from cust in custs
where cust.Country == "USA"
select new XElement("Customer",
from property in cust.GetType().GetProperties()
where property.Name!= "Orders"
select new XAttribute(property.Name, (property.GetValue(cust, null) == null ? "" : property.GetValue(cust, null)).ToString()),
new XElement("Orders",
from order in cust.Orders
select new XElement("Order",order.ShipCity, new XAttribute("OrderId",order.OrderID)))
));就是上面这段代码,提示说:成員存取 'System.Reflection.MemberInfo' 的 'System.String Name' 在型別 'System.Reflection.PropertyInfo[] 上不合法。
解决方案 »
- 如何给文件加上关键字??
- 强数据集+水晶报表的问题
- tabcontrol控件中的tabPage顺序问题!?
- 真的没有人帮我解决这个问题吗?显示时间与禁用关闭按钮 (已经困住我好几天了,急呀)
- 关于表单提交
- 帮忙解读一下一个包含Inner join 和 left outer join的SQL语句
- 编写的c#小程序把exe文件拷贝到其他win7系统能直接运行吗
- net有没有这个功能
- 添加窗体的时候,为什么没有windows form
- winform PictureBox重复载入图片,图却没有刷新
- WCF报错!The HTTP service located at "url" is too busy
- C# 中怎样得到ListView控件的data
至于转换成需要的类型之类的操作 最好在别的地方做
大概也许好象可能差不多是这个cust没有"name"属性。
你看下cust的定义吧,如果没问题就看看数据库里有没有这样的记录,保证取到的不是空值。
我没有NorthWind,我不用Linq TO sql的,你就不能把NorthwindDataContext相关声明贴出来吗?明明是自动产生的。