带有Guids的DataTable Select()

Ref*_*din 1 c# datatable guid .net-3.5

我试图在运行时从LINQ查询返回的DataTable中生成我的treeview.返回的字段是:

NAME = CaseNoteID | ContactDate | ParentNote TYPE = Guid | DateTime | GUID

ParentNote字段与CaseNoteID列中的条目匹配.Select(过滤器)给我一个无法找到列[ea8428e4]的运行时错误.该字母数字是其中一个Guids的第一部分.当我通过我的代码过滤器="ParentNote=ea8428e4-1274-42e8-a31c-f57dc2f189a4"

我错过了什么?

var tmpCNoteID = dr["CaseNoteID"].ToString();
                var filter = "ParentNote="+tmpCNoteID;

                DataRow[] childRows = cNoteDT.Select(filter);
Run Code Online (Sandbox Code Playgroud)

小智 6

尝试使用单引号括起GUID:

var filter = "ParentNote='"+tmpCNoteID+"'";
Run Code Online (Sandbox Code Playgroud)