Skip to content

This is a small component I wrote to translate my Telerik DataSourceRequest object from a DataGrid into a Mongo FluentAPI query.

Notifications You must be signed in to change notification settings

quintonv/TeleMongo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

TeleMongo

This is a small extension that I started writing to support Mongo from the Telerik DataSourceRequest object.

The extension method DataSourceRequest.GetPagedData() will translate the Telerik DataSourceRequest object from a DataGrid into a Mongo FluentAPI query and then execute it.

//Sample Code
public async Task<ActionResult> ReadSomeData([DataSourceRequest]DataSourceRequest request)
{
	try
	{
		var collection = MongoDB.GetMongoCollection<Model>("CollectionName");

		return Json(await request.GetPagedData<Model>(collection), 
            JsonRequestBehavior.AllowGet);
	}
	catch (Exception ex)
	{
		ModelState.AddModelError(string.Empty, ex.GetBaseException().Message);

		return Json(new List<Model> { new Model() }.ToDataSourceResult(request, 
		    ModelState), JsonRequestBehavior.AllowGet);
	}
}

About

This is a small component I wrote to translate my Telerik DataSourceRequest object from a DataGrid into a Mongo FluentAPI query.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages