0

我有以下数据结构 EntityObject (Unit, Product, ...) 1 : 1 Translation 1:n Translation Items。

要填充 ComboBoxes 和 listViews 我只需要以这种方式查询翻译:

    public CollectionViewSource GetShowColumns()
    {
        CollectionViewSource result = new CollectionViewSource();
        List<UnitDTO> units = new List<UnitDTO>();
        var qry = from x in _context.Units
                  select new
                  {
                      x.Name,
                      x.Name.Translations,
                      x.Id
                  };

        foreach (var temp in qry)
        {
            units.Add(new UnitDTO() { Id = temp.Id, Name = temp.Name });
        }
        result.Source = units;
        return result;
    }

我的 DTO 对象包含一个 Id 和 Translation 属性。

我已经使用EF Power Tools来生成视图。但是我仍然遇到冷热查询之间的巨大差异。

我该怎么办 ?

4

0 回答 0