This is a migrated thread and some comments may be shown as answers.

Data Access + WebAPI + MVC 4 Server Wrappers

4 Answers 184 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Allan
Top achievements
Rank 1
Allan asked on 07 Mar 2014, 03:22 AM
I'm attempting to create a new Kendo UI for ASP.NET MVC 4 project using the MVC Wrappers, Telerik Data Access for the data access layer, and WebAPI controllers, but not having much luck getting all three to work together.  It seems like it should be simple, but I'm not sure what I'm missing.

From the Data Access documentation, I can find examples of using Data Access with MVC or Data Access with WebAPI.  From the Kendo side of things, I can find tutorials on WebAPI and MVC Wrappers, the Binding to a Web ApiController sample project, the Facts on Using Kendo UI With ASP.NET WebAPI blog, and even the UI for ASP.NET MVC sample application has a grid using WebAPI.  But none of these resources seem to use all three of the pieces I'm trying to fit together.  I've tried studying the examples that use two of the three parts and modifying them to work with the third, but nothing seems to work.

Does anyone have a good, simple example of using a Data Access layer, with WebAPI, and MVC server wrappers or any pointers on how to modify the Binding to a Web ApiController project to use a Data Access layer instead?

Thanks!

4 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 07 Mar 2014, 09:45 AM
Hello Allan,

Pleas find attached a sample project which uses Telerik Data, WebAPI and ASP.NET MVC 4. It is based on the original WebAPI binding code library project. 

Regards,
Atanas Korchev
Telerik

DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

0
Allan
Top achievements
Rank 1
answered on 07 Mar 2014, 09:09 PM
Atanas, thanks for the fast reply!  I was able to replicate that with my own project and it worked like a charm.  
0
Garry
Top achievements
Rank 1
answered on 21 Mar 2014, 07:27 PM
Atanas,
Thank you for this sample, however I still have some conceptual questions please. It maybe that my knowledge isnt where it should be, but where I am having an issue is same setup as Alan, but I have three separate projects. I have a MVC 5 client app, an OpenAccess Web API service app, and an OpenAccess Model project.

Obviously the OpenAccess Web API has to know about the model and all of that is working perfectly, but where I get lost is on the client side consuming the Web API. In my mind the the client should have no knowledge about the OpenAccess model class, but without a WSDL/Contract to describe the model I am not sure how the client is going to function without knowledge of it. I have poured through the examples dealing with your UI for ASP.NET MVC controls, but they all including this one have a direct reference to OpenAccess Model
 
@(Html.Kendo().Grid<TelerikDataKendoGridWebApi.Product>()

Should I actually reference the OpenAccess model project in the MVC client app? That seems to coupled to me, however your controls and your examples all lead me to believe it to be true.

If I am incorrect do you mind providing another sample that shows how your controls can reference the Web API without sharing the OpenAccess project?

Thanks you,
Garry
0
Atanas Korchev
Telerik team
answered on 24 Mar 2014, 10:06 AM
Hello Garry,

The grid needs the type of the model in order to provide strongly-typed fluent interface. You can easily avoid referencing the OpenAccess project if you create another class which has the same properties as the OpenAccess model.

Regards,
Atanas Korchev
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
Tags
General Discussions
Asked by
Allan
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Allan
Top achievements
Rank 1
Garry
Top achievements
Rank 1
Share this question
or