看下面的代码
private static List<ExpandoObject> GetDBDetails()
{
var directoryPath = Environment.CurrentDirectory.Replace("\\bin\\Debug", "\\DataSource");
var filePath = Path.Combine(directoryPath, "DBDetail.xml");
try
{
//Load xml
XDocument xdoc = XDocument.Load(filePath);
if (xdoc == null) return null;
List<ExpandoObject> dbDetails = (from dbDetail in xdoc.Descendants("database")
select new ExpandoObject
{
DBDetailId = Convert.ToInt32(dbDetail.Attribute("dbDetailId").Value),
DBServerId = Convert.ToInt32(dbDetail.Attribute("dbServerID").Value)
});
return dbDetails;
}
catch (Exception ex)
{
McAfee.EnterpriseLibrary.Logging.LogUtil.LogEntry(ex, System.Diagnostics.TraceEventType.Critical);
return null;
}
}
我收到错误
System.Dynamic.ExpandoObject' 不包含 'DBDetailId' 的定义 System.Dynamic.ExpandoObject' 不包含 'DBServerId' 的定义
如何纠正这种情况?