OData implementation for ASP.NET MVC

We have a fairly simple line of business applications implemented with ASP.NET MVC2, and we have a new requirement to be able to share our data with other parts of the business, including SharePoint 2010, Ruby and Python.

I would like to use OData as a transport mechanism (as opposed to SOAP) using our existing MVC application. I am struggling to find those who mention the OData provider implementation for MVC.

Can you suggest how I can start my own OData ASP.NET MVC provider or point me somewhere that may have already started something like this?

+3
source share
2 answers

OData MVC MVC Web API.

. OData :

public class ProductController : EntitySetController<Product, int>
{
    private readonly IUnitOfWork _unitOfWork;

    public ProductController(IUnitOfWork unitOfWork)
    {
        _unitOfWork = unitOfWork;
    }

    public override IQueryable<Product> Get()
    {
        return _unitOfWork.Repository<Product>().Query().Get();
    }

    protected override Product GetEntityByKey(int key)
    {
        return _unitOfWork.Repository<Product>().FindById(key);
    }

    protected override Product UpdateEntity(int key, Product update)
    {
        update.State = ObjectState.Modified;
        _unitOfWork.Repository<Product>().Update(update);
        _unitOfWork.Save();
        return update;
    }

    public override void Delete([FromODataUri] int key)
    {
        _unitOfWork.Repository<Product>().Delete(key);
        _unitOfWork.Save();
    }

    protected override void Dispose(bool disposing)
    {
        _unitOfWork.Dispose();
        base.Dispose(disposing);
    }
}

: http://blog.longle.net/2013/06/18/mvc-4-web-api-odata-entity-framework-kendo-ui-grid-datasource-with-mvvm/

0

Source: https://habr.com/ru/post/1768580/


All Articles