My flow is to take data from a SQL Server database (I'm using datatable) and then publish it to the PubSub (different message for each row). May someone help and suggest me the way in doing it?
I am using Newtonsoft.Json to convert to JSON.
This is my connection to the database:
public DataTable RequestDataDB()
{
SqlConnection database = new SqlConnection(DatabaseConn.DBConnectionString);
database.Open();
SqlCommand databaseCmd = new SqlCommand("Request_PubData", database);
SqlDataAdapter da = new SqlDataAdapter(databaseCmd);
da.Fill(dt);
database.Close();
return dt;
}
This how I call it back and convert to JSON & publish it.
Console.WriteLine("Data to be Published Total : " + totalRows);
string jsonOutput = JsonConvert.SerializeObject(RequestDataDB, Formatting.Indented);
string messageId = await publisher.PublishAsync(jsonOutput);
Console.WriteLine(jsonOutput);
await publisher.ShutdownAsync(TimeSpan.FromSeconds(15));
Thank you for your help.