Query Issue

Jul 13, 2016 at 7:51 PM
Edited Jul 13, 2016 at 7:52 PM
I have a document store and view configured. I am attempting to query the store and see different results based on how I query. Looking at the examples below, var q and t return 1 row (as expected) but p returns 0 rows.
var q = rdb.Query<RaptorItems.RaptorViewSchema>(x => x.SourceId == "C4-0B-FB-8C-5F-7B-A5-5A-C0-1A-AC-58-BA-CC-A1-3C");

var p = rdb.Query<RaptorItems.RaptorViewSchema>(x => x.SourceId == xrefs[i].Id);

string val = xrefs[i].Id;
var t = rdb.Query<RaptorItems.RaptorViewSchema>(x => x.SourceId == val);
Is there a specific reason that p would not return a result?
Coordinator
Jul 14, 2016 at 4:52 AM
Writing a LINQ parser is hard!

I will look into extracting second/multi level values from right hand side parameters.
Jul 14, 2016 at 11:39 AM
Thanks for the reply. No doubt writing the parser is hard. I wasn't sure if I was doing something wrong or not.
Jul 14, 2016 at 12:16 PM
I implemented the following method to perform my query lookup.
string val = xrefs[i].Id;
var t = rdb.Query<RaptorItems.RaptorViewSchema>(x => x.SourceId == val);
I then proceed to validate the row count and attempt to Fetch an object.
XmlDocumentSpec parent = null;
if (t.Rows.Count != 0)
{
     Guid docid = t.Rows[0].docid;
     parent = (XmlDocumentSpec)rdb.Fetch(docid);
}
The fetched row throw an error in my implementation of GetHashCode() override stating that the object data is NULL. Can you point me in a direction to look to validate that the object I am saving is getting written correctly and/or that the data fetched is being retrieved correctly? If I debug, I can see the object returned is not NULL but all items inside are.

Thanks in advance for any help!
Coordinator
Jul 14, 2016 at 12:26 PM
Check the log files first.

If the data appears in the view then the doc was saved, however I'm not sure XmlDocumentSpec is being serialized to json properly, to check do:
string json = fastJSON.JSON.ToJSON(XmlDocumentSpecObj); // check the json value looks right
Jul 14, 2016 at 12:39 PM
Checking the logs, I do not see anything outstanding.
2016-07-14 08:35:31|DEBUG|8|RaptorDB.RaptorDB|| 

RaptorDB starting...
2016-07-14 08:35:31|DEBUG|8|RaptorDB.RaptorDB|| RaptorDB data folder = C:\Temp\programming\SqlNoSqlTesting\SqlNoSqlRaptor\bin\Debug\raptor\
2016-07-14 08:35:31|DEBUG|8|RaptorDB.KeyStore`1|| Current Count = 0
2016-07-14 08:35:31|DEBUG|8|RaptorDB.KeyStore`1|| Checking Index state...
2016-07-14 08:35:31|DEBUG|8|RaptorDB.KeyStore`1|| Starting save timer
2016-07-14 08:35:31|DEBUG|8|RaptorDB.KeyStore`1|| Current Count = 0
2016-07-14 08:35:31|DEBUG|8|RaptorDB.KeyStore`1|| Checking Index state...
2016-07-14 08:35:31|DEBUG|8|RaptorDB.KeyStore`1|| Starting save timer
2016-07-14 08:35:31|DEBUG|8|RaptorDB.Views.TaskQueue|| TaskQueue starting
2016-07-14 08:35:31|DEBUG|8|RaptorDB.Hoot|| Starting hOOt....
2016-07-14 08:35:31|DEBUG|8|RaptorDB.Hoot|| Storage Folder = C:\Temp\programming\SqlNoSqlTesting\SqlNoSqlRaptor\bin\Debug\raptor\Data\Fulltext\
2016-07-14 08:35:31|DEBUG|8|RaptorDB.KeyStore`1|| Current Count = 0
2016-07-14 08:35:31|DEBUG|8|RaptorDB.KeyStore`1|| Checking Index state...
2016-07-14 08:35:31|DEBUG|8|RaptorDB.KeyStore`1|| Starting save timer
2016-07-14 08:35:31|DEBUG|8|RaptorDB.Views.ViewHandler|| RaptorDB view engine upgrade, rebuilding view : XmlDocumentSpecView
2016-07-14 08:35:31|DEBUG|8|RaptorDB.Views.ViewHandler|| Deleting old view data folder = XmlDocumentSpecView
2016-07-14 08:35:31|DEBUG|11|RaptorDB.Views.ViewHandler|| Rebuilding view from scratch...
2016-07-14 08:35:31|DEBUG|11|RaptorDB.Views.ViewHandler|| View = XmlDocumentSpecView
2016-07-14 08:35:31|DEBUG|11|RaptorDB.Views.ViewHandler|| Documents processed = 0
2016-07-14 08:35:31|DEBUG|11|RaptorDB.Views.ViewHandler|| rebuild view 'XmlDocumentSpecView' done (s) = 0
2016-07-14 08:38:44|DEBUG|8|RaptorDB.Views.ViewHandler|| query : XmlDocumentSpecView
2016-07-14 08:38:44|DEBUG|8|RaptorDB.Views.ViewHandler|| query bitmap done (ms) : 9.5073
2016-07-14 08:38:44|DEBUG|8|RaptorDB.Views.ViewHandler|| query rows fetched (ms) : 5.5045
2016-07-14 08:38:44|DEBUG|8|RaptorDB.Views.ViewHandler|| query rows count : 1
Reviewing the json string as you specified looks correct, to me. However, I do not have a lot of exposure to json.
{"$types":{"XmlImport.XmlDefinitions.XmlDocumentSpec, XmlImport, Version=16.0.0.7, Culture=neutral, PublicKeyToken=null":"1"},"$type":"1","SourceId":"C4-0B-FB-8C-5F-7B-A5-5A-C0-1A-AC-58-BA-CC-A1-3C","SourceName":"24177-2 ENCODER ASSEMBLY.SLDASM","SourcePath":"M:\\Tim-Pi","SourceFullPath":"M:\\Tim-Pi\\24177-2 ENCODER ASSEMBLY.SLDASM","SourcePathId":"54-FE-3E-A2-ED-20-E3-A4-A5-A4-9B-13-6A-FF-0C-91","SourceExtension":".sldasm","SourceCreationDate":"05/10/11 4:57:47 PM","ImportId":"1","ImportName":"24177-2 ENCODER ASSEMBLY.SLDASM","ImportPathId":"741","IsSupportedCadFormat":true,"IsSolidWorksFormat":true,"RemovedFromIndices":false}
In the above, is there something incorrect that I am simply missing?
Coordinator
Jul 15, 2016 at 7:38 AM
Sorry, I can't get the linq parser to work with array indexed parameters, use a local variable first.
Coordinator
Jul 15, 2016 at 7:39 AM
Use the debugger and see if your parent variable looks valid.
Jul 18, 2016 at 11:36 PM
Everything looked correct. I did update my override for GetHashCode() to include a check for the default value as shown below.
public override int GetHashCode()
        {
            if (this == null || this.SourceId == null)
                return -1;

            return this.SourceId.GetHashCode();
        }
Adding the this.SourceId == null check allowed the Fetch command to work.