Before any assembly can be loaded your server needs to have CLR enabled. The following SQL will enable it:
sp_configure 'clr enabled', 1
go
reconfigure
go
The assembly needs to be initialised with a device data file. Therefore before using any of the methods the following initialisation statement should be run once with the local server path to the 51Degrees device data file.
SELECT dbo.InitialiseDeviceDetection('[YOUR V3 DEVICE DATA FILE]', NULL, 10, 1);
The second parameter provides a list of the properties that should be returned for a detection. The third parameter is the number of seconds a result should be held in the cache before it is discarded. The final parameter is a Boolean to indicate if the data file should be loaded into main memory for faster performance (true), or retained on disk to reduce main memory consumption (false).
The following line will initialise the detection service using main memory to return the DeviceType, IsMobile and ScreenInchesDiagonal with a cache life of 60 seconds.
SELECT dbo.InitialiseDeviceDetection('D:\51Degrees.dat', 'DeviceType, ScreenInchesDiagonal, IsMobile', 60, 1);
Following initialisation properties can be queried directly using the DevicePropertyByUserAgent method. The first parameter is the target User-Agent, the second the property required.
The following example returns the IsMobile property for a User-Agent which represents the Google Nexus 4.
SELECT dbo.DevicePropertyByUserAgent('Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 4 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19', 'IsMobile');