Query GUID type value from database

Query GUID type value from database

quan_hm
Collaborator Collaborator
422 Views
0 Replies
Message 1 of 1

Query GUID type value from database

quan_hm
Collaborator
Collaborator

I was trying to query the SizeRecordId, its type value is GUID (check with SQL lite).

 

I was following this post: https://adndevblog.typepad.com/autocad/2012/12/plant-sdk-sample-of-pnptableselect.html

 

to use PnPTable.Select(). So far every type (string, double) is query successful but not the one with type GUID, in this case is SizeRecordId field.

 

So my code was like this:

 

PipePartSpecification pps = PipePartSpecification.OpenSpecification(spec_file);
                PnPTable fittingsTable = pps.Database.Tables["EngineeringItems"];
string query = "\"SizeRecordId\"=X\'0C3BE84B27D5B447BCFC9EDFB4D9A09D\'";
                PnPRow[] matchDtRows = fittingsTable.Select(query);
PnPRow[] matchDtRows = fittingsTable.Select(query);

 

when running P3D give me this error:

minhquanqttb_1-1680243357606.png

 

But the same query I was using will work in SQL Lite:

minhquanqttb_0-1680243182141.png

You can wonder why the real value is "4BE83B0C-D527-47B4-BCFC-9EDFB4D9A09D" but the query is different, this is the reason: https://stackoverflow.com/questions/7815587/using-guid-in-sqlite-select-where-guid-is-stored-in-the-...

 

For short explain you have to convert it to little endian before doing the query for GUID type value.

 

Really appreciate your guys help.

 

Hoang Minh Quan - Lead Developer

Autodesk Store for IntegaDesign Content

Smart Solutions by IntegaDesign

Plant 3D • CAD Optimization • Automation
0 Likes
423 Views
0 Replies
Replies (0)