//.. Controller
// GET: api/TodoItems
[HttpGet]
public async Task<ActionResult<IEnumerable<TodoItem>>> GetTodoItems()
{
//......manual eklemek..................
_context.TodoItems.Add(new TodoItem { Id = 1, Name = "test_1", IsComplete = false });
_context.SaveChanges();
//.......... metod la eklemek
var ti = new TodoItem { Id = 2, Name = "test_2", IsComplete = false };
await PostTodoItem(ti);
//........................
return await _context.TodoItems.ToListAsync();
}
//.. startup.cs
public void ConfigureServices(IServiceCollection services)
{
//.................................
services.AddDbContext<TodoContext>(opt =>
opt.UseInMemoryDatabase("dbTodoList"));
//.................................
services.AddControllers();
}
Yorumlar
Yorum Gönder