The attached plugin is a useful plugin put together to help with converting .NET
DataTables to JSON formatted strings, that can be passed through
WCFServices without compromising the plumbing.
I put it together because I have developed a lot of custom .NET libraries for use with
WCFServices and given the JSON footprint and mobile access to data. I just wanted to have a solution I can easily integrate into my existing applications without having to build new ones.
As I mentioned in the introduction, I am mostly a Windows platform developer, and have a deep love for
WCFServices. However, with the proliferation of mobile devices and applications, data consumption needs to be treated with great care by developers. When it comes to transmission format, I recently got wind of JSON and how it seems to be a de-facto mobile data transmission format and have put together a small library (download attached) to help those like myself.
Using the Code
.NET Platform: 4.0
In Visual Studio --> Solution Explorer
- Right click on your project and select Add Reference
- Select Browse tab and navigate to the location of your decompressed file
- Select Munhemba.DataTableToJSON.dll
For C#, do the following:
Within your code, declare the library as follows:
public string GetTableRowsJSON()
string jsonData = null;
using ([yourDataSetName] [yourDataSet_Alias] = new [yourDataSetName]())
[yourTableAdapterAlias] = new [yourDataSetName]TableAdapters.[YourTableNameAdapter]();
Munhemba.DataTableToJSON dtToJSON =
jsonData = dtToJSON.outputString;
You may expose the
GetTableToRows function through a
WCFService the normal way and still get to benefit from the plumbing that comes along with WCF, such as
Points of Interest
I believe that applications and databases can no longer in fact, should not exist in isolation. WCF provides a tested platform for CRUD on a variety of databases, personally having worked with MSSQL Server, MySQL, ORACLE, and having integrated some of them, I find the JSON format becoming a versatile companion to WCF because of the lightness (message size) of the data transmitted, then again the good relationship it has with JQuery makes it all worth the while to look into and consider.
- First article posted 03 November 2013