Sivakumar

Sivakumar

  • NA
  • 551
  • 210.8k

I am getting an error when fetching data from database

Oct 2 2015 7:15 AM
Hi,
 
I implement one web api like this :
 
[Authorize]

[RoutePrefix("api/Notifications")]
public class NotificationsController : BaseController
{

private NotificationManager _notification = new NotificationManager();


[Route("")]
//api/notifications
public IEnumerable<Notification> GetNotifications()
{
return GetNotifications();
}
} 
 
This is my dataaccess layer class :
 
 
public IEnumerable<Notification> GetNotifications()
{
using (KiwiDbContext context = new KiwiDbContext(_ConnectionString))
{
return context.Notifications.ToList();
}
}

This is my business layer :
 
public class NotificationManager
{
private DataAccess _kiwidb = new DataAccess();

public List<Notification>GetNotification()
{
return _kiwidb.GetNotifications().ToList();
}
} 
 
 
This is my table :
 
 
 
When I execute my project get an error like this :
 
 
 
An unhandled exception of type 'System.StackOverflowException' occurred in Kiwi.Service.API.Controller.dll 
 
Please give me a correct code for that.
 

Answers (1)