【问题标题】:How can I read LINQ group by Query?如何通过查询读取 LINQ 组?
【发布时间】:2010-10-08 15:14:25
【问题描述】:

这是我的 escenary,我有一个名为 Plantilla 的类,其中包含允许在 wpf 中绑定一个 gridview 的多个属性,所以这已经工作了,但是用户告诉我他们需要通过数据库中的某个字段重新组合查询,所以我准备了这个 sn-p:

  var dsTemplates = (from t in db.PLANTILLAs
                                   join q in db.EQUIPOs on t.codigoequipo equals q.codigoequipo
                                   where t.codigoestudio.Substring(5, 1).Equals(codigoModalidad)
                                   orderby t.tituloplantilla
                                   group new Plantilla
                                   {
                                       codigoplantilla = t.codigoplantilla,
                                       codigoequipo = t.codigoequipo,
                                       nombreequipo = q.nombreequipo,
                                       codigoestudio = t.codigoequipo,
                                       conclusion = t.conclusion,
                                       hallazgo = t.hallazgo,
                                       nombreexamen = t.tituloplantilla,
                                       tecnica = t.tecnica
                                   } by t.codigoestudio
                ).ToList();
                formTemplates.dlstPlantillas.ItemsSource = dsTemplates;
                db.Connection.Close();

现在我的问题是如何阅读以下内容?在哈希表中?如何将泛型转换为 Hashtable?因为当 T 是我的类 Plantilla 时,我现在有一个列表

我将它绑定到一个gridview,所以当我想从grid获取值时我得到异常

debug 告诉我这是我在 gridview.SelectedItems[0] 中的新集合类型;

[0] = {System.Data.Linq.SqlClient.ObjectReaderCompiler.Group<string,Demo.View.Plantilla>}

【问题讨论】:

    标签: linq hashtable group-by


    【解决方案1】:

    在您的网格视图中,您可以将索引字段设置为返回的 var 中的必填字段。然后,这将为您提供编辑的每一行的 PK。

    【讨论】:

    • 我正在使用 WPF,带有 Grid 和 ListView 我在哪里可以找到该属性?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多