Query records example using .NET SDK

I would like to build a custom search page (using MVC/Razor) that uses the .NET SDK to search for records.

I have a basic template that works, but the query is much slower than the Service API (in the Web Drawer). Are there any helper methods, etc. in the SDK that can assist in making a more efficient/faster query:

It would be something like:

MainTrimObjectSearch records = new MainTrimObjectSearch(database, BaseObjectTypes.Record);
records.SetSearchString("uri:123456"); //Search criteria supplied by search form

var results = from r in records
select r.Skip(15).Take(15);

View(results);

This performs slow when querying 100s/1000s of records.

Parents
  • Hi there,

    I think it's taking longer because the lines:

    MainTrimObjectSearch records = new MainTrimObjectSearch(database, BaseObjectTypes.Record);
    records.SetSearchString("uri:123456"); //Search criteria supplied by search form
    var results = from r in records select r.Skip(15).Take(15);

    will make it return all results, and then return the subset of 15 results. Instead, you'd want:

    MainTrimObjectSearch records = new MainTrimObjectSearch(database, BaseObjectTypes.Record);
    records.SetSearchString("uri:123456"); //Search criteria supplied by search form
    records.SkipCount = 15;
    records.LimitOnRowsReturned = 15;

    That might speed things up?

    Matt

     

  • Matt,

    Thanks. I will try it out tommorrow (as I don't have access to the code at home).

    What about querying specific properties to be returned in the query?

    Using the same example I gave you, most of the UDFs I need are not accessible using dot notatioon on the Record object (i.e. Record.RecordNumber, Record.RecordTitle). I can see them in the XML string from the Record.DataFormDefinition (? not sure the exact name), but how can I do a query that queries both user defined properties and default properties on the Record object?

  • Field are not available via the dot notation, you need to use either GetFieldValueAsString() or GetFieldValue(), e.g.:

    rec.GetFieldValueAsString(new FieldDefinition(database, "MyField"),StringDisplayType.Default, false);

    or:

     rec.GetFieldValue(new FieldDefinition(database, "MyField"));
Reply Children