嗨,我在读取字典中给出了 id 的数据表时遇到了问题。请任何人帮助我。下面是我的代码。我有一个字典 datasourceData 我正在存储数据表。我需要为给定的 id 检索存储在字典中的数据表。
public Dictionary<Guid, DataTable> dataSourceData { get; set; }
public DataModel()
{
dataSourceData = new Dictionary<Guid, DataTable>();
logger = new BasicFileLogger.Logger();
}
public DataTable GetDataSourceDescriptionById(Guid piId)
{
if (piId == null || piId == Guid.Empty)
throw new InvalidOperationException("No such datasourcedescriptionId");
try
{
return dataSourceData.Values.Where(db => db.Equals(piId));
}
catch (Exception ex)
{
logger.WriteException(ex);
throw new InvalidOperationException(ex.Message);
}
}
请帮忙?