The generated API is a strongly-typed API that matches your dGraph. After defining a dGraph you have a model created that matches your specific data needs. The generic API provided out of the box does provide all the functionality your need however it is not strongly-typed. This is akin to dataset in VS.NET. It works fine however you have to reference fields by name and you can fat-finger data. The generated API allows you to create an API that can be access with Intellisense in the VS.NET environment. All fields, sorts, dimensions, rollups, etc are accessed with objects of the appropriate name with no loose types. Instead of using strings, you use custom objects created for each of your fields, sorts, etc.
I will use some code snippets to demonstrate the power of a strongly-typed API. First to register a dGraph inside of an application you need to call the register functionality.
For the generic API, you must specify the dGraph name which you might mistype. The generated API which only wants a connection string.
Generic API
UrlQuery.dGraphRegister("Autos", "database=…;password=…;etc");
Generated API
AutoItemUrlQuery.dGraphRegister("database=…;password=…;etc");
That snippet was not that useful however the using the returned strong objects is very useful.
Generic API
UrlQuery query = new UrlQuery();
QueryResults results = new QueryResults(query);
results.Execute();
foreach (IRecord item in results.DRecords)
{
a = item.Values["Address"].Value;
b = item.Values["City"].Value;
c = item.Values["DatePosted"].Value;
}
Generated API
AutoItemUrlQuery query = new AutoItemUrlQuery();
AutoItemCollection autoItemCollection = new AutoItemCollection(query);
autoItemCollection.Execute();
foreach (AutoItem item in autoItemCollection)
{
a = item.Address;
b = item.City;
c = item.DatePosted;
}
The above example is very important. Notice that all fields on the AutoItem object as compiled fields. You can get Visual Studio Intellisence and compile type error checking. You cannot fat finger some text string and get a run-time error. The code is also a lot more readable. Also notice that listing object is of type "AutoItem" as opposed to the generic "DRecord". This ensure better readability as well as compile-time error checking. If you change your dGraph schema, simply regenerate and your strongly-typed API is updated. When you try to compile your application, the Visual Studio compiler will tell your the errors (if any) caused by your changes.





