【发布时间】:2020-03-28 00:22:38
【问题描述】:
我在视图中有一个表(Geraete),它还通过使用公共虚拟键 Ort(Foreignkey to Table Orte) 访问另一个表来显示外部表中的数据。这很好用,但我的问题是当我想对外部值列进行排序时,以下代码 sn-p 不起作用:
//test.Sortcolumn(String Value of the Column name which should be sorted)
var pi = typeof(Geraete).GetProperty("test.SortColumn");
//movie.Typens is from Type List Geraete
movie.Typens = (from t in movie.Typens select t).OrderBy(x => pi.GetValue(x, null)).ToList();
是的,这个片段适用于相同实体类型 Geraete 的列。 在视图中,可以通过使用 Ort.Columnname 轻松访问外部表的值,但这也不适用于上面的代码 sn-p。
【问题讨论】:
标签: c# asp.net-core entity-framework-core