WebApi and ODataModelBuilder

Posts   
 
    
zaifworks
User
Posts: 2
Joined: 15-Aug-2013
# Posted on: 15-Aug-2013 03:05:02   

I am using LLBLGen Pro v 4.0 Final July 18th Build. I would like to use LLBLGen Pro Runtime Framework for this project.

What I am attempting to do is define a model using ODataModelBuilder for my exposed entities using a WebApi (EntitySetController).

In order to define this model, I have to do something like this:

ODataModelBuilder modelBuilder = new ODataConventionModelBuilder(); modelBuilder.EntitySet<AssetEntity>("Assets"); modelBuilder.EntitySet<AssetTypeEntity>("AssetTypes");

I would like to wire up these entities to webapi controllers (EntitySetContoller) so that they can be exposed and consumed by a AngularJS Client.

I am not sure if this is possible. Any help would be greatly appreciated.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 15-Aug-2013 07:48:28   

Hi there.

  • So you are generating code for LLBGen Runtime Framework, right?
  • Did you already read the WCF Data Services section on the documentation?
  • Please elaborate more on why you need to use that ModelBuilder. You can use whatever you want with AngularJS, Right?
David Elizondo | LLBLGen Support Team
zaifworks
User
Posts: 2
Joined: 15-Aug-2013
# Posted on: 15-Aug-2013 17:18:11   

Thanks for the quick response. I really love this product and the service!

  • Yes, I am generating code for the LLBLGen Runtime Framework. The reason I phrased it as as such was because I could use Entity Framework and then Model is predefined and I could get the model from the context. I would rather use LLBLGen Runtime.

  • I have indeed looked at the WCF Data Services section. I have used that for a previous project and it works great. I am trying to get something similar working but only with the WebApi "framework"

  • The ModelBuilder (as I understands it) explicitly defines the model that would be exposed via the controllers. This would help generate the metadata that I could use on the client side and not have to manually define json DTO.

  • You are correct, Angular would work with either type of service. If webapi doesn't work I would use WCF Data Services. To be Honest, I am unsure as to the true benefits of using WebApi over WCF DataServices. So far I have only discovered that I can override the web methods (/get -> get()) to customize the logic as I need so long as they return the same IQueryable<T>. Instead of say relying on query interceptors.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 16-Aug-2013 06:55:37   

You can use LLBLGen entities as the model and WebApi. Just decorate your classes. See LLBLGen and WebApi support for more information.

David Elizondo | LLBLGen Support Team