我似乎无法将“实体”加载到字典中。尝试向字典中添加任何内容时,我得到一个“未设置对象实例的对象引用” 。任何帮助是极大的赞赏。
private TranslationEntities _db = new TranslationEntities();
private Dictionary<int, Language> _data;
private void LoadData()
{
var languages = _db.Languages.Include("Region").OrderBy(e => e.Region.Name).ThenBy(e => e.Name);
foreach (Language item in languages)
{
_data.Add(item.Id, item); //// ERRORS HERE ////
}
}