I have 4 layers
Controller Layer
public class BaseMapController : ApiController { /// <summary> /// Create an object for service layer interface and inject the object usinng constructor injection /// </summary> /// public BaseMapController() { } private IBaseMapServiceInterface _basemapServiceInterface; public BaseMapController(IBaseMapServiceInterface thebasemapServiceInterface) { _basemapServiceInterface = thebasemapServiceInterface; } [HttpGet] public IEnumerable<MasterTblModel> GetSearch() { return _basemapServiceInterface.GetSearch(); } }
}
Service Layer
public class BaseMapServiceInterfaceImpl : IBaseMapServiceInterface { /// <summary> /// Create an object for data access layer interface and inject the object usinng constructor injection /// </summary> /// <returns></returns> private IBaseMapDataInterface _basemapDataInterface; public BaseMapServiceInterfaceImpl(IBaseMapDataInterface thebasemapDataInterface) { _basemapDataInterface = thebasemapDataInterface; } public IEnumerable<MasterTblModel> GetSearch() { return _basemapDataInterface.GetSearch(); } }
DataAccessLayer
public class BaseMapDataInterfaceImpl : IBaseMapDataInterface { public IEnumerable<MasterTblModel> GetSearch() { using (KGISApplication_Context Con = new KGISApplication_Context()) { **return (IEnumerable<MasterTblModel>)Con.MASTER_TBL;** } } }
Model class
public class MasterTblModel { public string MASTER_TBL_ID { get; set; } public string category { get; set; } public string Layer_Name { get; set; } public string table_alias { get; set; } }
solution is not have any compile time error, when I run it is showing 'System.Data.Entity.DbSet1[DataAccessLayer.MASTER_TBL]' to type 'System.Collections.Generic.IEnumerable
1[KGISModels.MasterTblModel]'.' from the data access layer
I did all the effort to type cast and change the linq query style, but could not able to fix. Any help will be helpful. For DI I have used unity framework and registered the interface to implementation class properly.