動的 linq を使用して、列を動的に選択しています。私はこれについて明確にする必要があります。どうすればこれを行うことができますか?
var qry = tbl.AsEnumerable().AsQueryable()
.Select("new(it[\"" + this.UniqueName + "\"]
.ToString() as " + this.UniqueName + ")");
ありがとう。
動的 linq を使用して、列を動的に選択しています。私はこれについて明確にする必要があります。どうすればこれを行うことができますか?
var qry = tbl.AsEnumerable().AsQueryable()
.Select("new(it[\"" + this.UniqueName + "\"]
.ToString() as " + this.UniqueName + ")");
ありがとう。
使用する代わりに
as " + this.UniqueName + "
行う
as someFixedColumnName
Distinct()
通常のLinqを使用して、その句を実行します。
または、次の拡張メソッドを試すこともできます。
public static IQueryable DynamicDistinct(this IQueryable source)
{
if (source == null) throw new ArgumentNullException("source");
return source.Provider.CreateQuery(
Expression.Call(
typeof(Queryable), "Distinct",
new Type[] { source.ElementType },
source.Expression));
}