Custom EntityFramework Provider
The following article demonstrates how to implement a custom provider for the RadGantt, using EntityFramework. For a simpler sample using generic collections see the RadGantt with Simple CustomProvider using collections in Session KB article.
Implementing Custom Provider, using EntityFramework.
In order to implement a custom provider for the RadGantt you would need to create a class that inherits the GanttProviderBase class. The custom class should implement the GetTasks, UpdateTask, DeleteTask and InsertTask - regarding the Task object and GetDependencies, DeleteDependency and InsertDependency - regarding the Dependencies object. The following steps will help you to easily create and implement a custom provider for the RadGantt, using EntityFramework.
-
Initially, you would need to create your EntityFramework model, which should actually translate the underlying data tables as object so that they could be easily managed in the custom provider class.
-
Create a class that should inherit the GanttProviderBase class.
public class GanttProvider : GanttProviderBase
{
}
- In the custom class you should implement the Get, Update, Delete and Insert methods using the EntityFramework DBContext for both Task and Dependencies objects.
public override List<ITask> GetTasks()
{
...
}
public override ITask UpdateTask(ITask task)
{
...
}
public override ITask DeleteTask(ITask task)
{
...
}
public override ITask InsertTask(ITask task)
{
...
}
public override List<IDependency> GetDependencies()
{
...
}
public override IDependency DeleteDependency(IDependency dependency)
{
...
}
public override IDependency InsertDependency(IDependency dependency)
{
...
}
The Dependency object should not implement an Update method, as it does not possess such functionality. In addition, the methods should return object of type Task and Dependency.
- Provide the RadGantt control with the newly created custom provider at the Page_Load in the following manner:
protected void Page_Load(object sender, EventArgs e)
{
RadGantt1.Provider = new GanttProvider();
}
Here you can find a code library with a runnable sample project, created based on the above instructions.