当我运行它(它说“无法确定属性名称”)时,出现InvalidOperationException异常。我检查了网络,但没有找到解决办法。它发生在foreach(联系人中的var c)行。使用Datacontext的InvalidOperationException
DataContext ctx = new DataContext("CrmConnection");
var contacts = from c in ctx.contacts
where c != null
select new
{
acct = c.parentcustomerid == null ? "" : c.parentcustomerid.name,
last = c.lastname == null ? "" : c.lastname,
first = c.firstname == null ? "" : c.firstname
};
List<string> lines = new List<string>();
try
{
foreach (var c in contacts) *ex*
{
Console.WriteLine(c.acct);
Console.ReadLine();
lines.Add(string.Format("{0}\t{1}\t{2}", c.acct, c.last, c.first));
Console.WriteLine(c.acct);
}
}
catch (Exception ex)
{
Console.WriteLine(String.Format("Error: {0}", ex));
}
让我知道你是否有任何想法。谢谢。
什么是* * * *? – devuxer 2012-02-16 00:29:10
这是你正在得到的确切的错误信息,还是有更多的呢? – Matt 2012-02-16 03:02:32
* ex *是我添加的,它是 – Paul 2012-02-16 14:38:25