0
votes

I have a Azure Mobile App project which by default created TodoItem table controller. I also have a DAL project which uses EF6 Entity Data Model which is referred in my other ASP.Net MVC project.

I wish to use the same DAL project in my app project instead redefining each entities again. I understand that for Table Controller, these entities need to be derive from EntityData. And the one in DAL project are not, e.g. as below

namespace DAL.Model
{
   using System;
   using System.Collections.Generic;

   public partial class TodoItem
   {
      public System.Guid Id { get; set; }
      public string Text { get; set; }
      public Nullable<bool> Complete { get; set; }
   }
}

Am aware that I can inherit the DAL project using API Controller, but want to check possibility of using TableController in this context.

1

1 Answers

1
votes

What you could do is follow what this example does. It has an existing model and uses DTOs to create a "mobile" version of them that does have the EntityData inheritance.

You can then create a map between your DAL project items and your Mobile Items.

For example:

Mapper.Initialize(cfg =>
{
    cfg.CreateMap<MobileOrder, Order>();
    cfg.CreateMap<MobileCustomer, Customer>();
    cfg.CreateMap<Order, MobileOrder>()
        .ForMember(dst => dst.MobileCustomerId, map => map.MapFrom(x => x.Customer.Id))
        .ForMember(dst => dst.MobileCustomerName, map => map.MapFrom(x => x.Customer.Name));
    cfg.CreateMap<Customer, MobileCustomer>();

});

You then create a domain manager to manage the logic between the two, and use that to create your Table Controller for your Mobile Service.