You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@meninjanho4788 the project demonstrate Azure sql storage rather sql 2016.
As I understand, In order to access azure sql storage you need to register custom services in the project to get access to command and query:
public void ConfigureServices(IServiceCollection services)
{
const string ConnString = "Server=db.database.windows.net;Database=TodoDb;User Id=usr;Password=pwd";
services.AddTransient<IQueryPipe>( _=> new QueryPipe(new SqlConnection(ConnString)));
services.AddTransient<ICommand>( _=> new Command(new SqlConnection(ConnString)));
// Add framework services.
services.AddMvc();
}
Then use these services in controller:
public class TodoController : Controller
{
private readonly IQueryPipe SqlPipe;
private readonly ICommand SqlCommand;
public TodoController(ICommand sqlCommand, IQueryPipe sqlPipe)
{
this.SqlCommand = sqlCommand;
this.SqlPipe = sqlPipe;
}
// GET api/Todo
[HttpGet]
public async Task Get()
{
await SqlPipe.Stream("select * from Todo FOR JSON PATH", Response.Body, "[]");
}
}
Same works for other CRUD operations. From Client side, it should be same setup to call these restful enpoints. I have never used Azure sql database. Perhaps above explanation will point you to right direction.
Closing this because of unrelated to this project.
Thank you Sir.
how to apply this example in link below to this project.
https://www.codeproject.com/Articles/1106622/Building-REST-services-with-ASP-NET-Core-Web-API-a
it get data json from sql 2016 and not use model, response, interface in server.
The text was updated successfully, but these errors were encountered: