Ejemplo n.º 1
0
        public static HttpResponseMessage title(HttpRequestMessage req,
                                                [HttpTrigger] TitleRequest parameters,
                                                [SQLDatabase(ConnectionString = "ConnectionString",
                                                             SQLQuery = "SELECT * FROM Book WHERE Title LIKE CHAR(37)+'{title}'+CHAR(37)")]
                                                string jsonTable,
                                                TraceWriter log)
        {
            log.Info("title|json: C# HTTP trigger function processed a request.");

            //log.Info(jsonTable);

            return(new HttpResponseMessage(HttpStatusCode.OK)
            {
                StatusCode = HttpStatusCode.OK,
                Content = new StringContent("{ \"Data\": " + jsonTable + " }", Encoding.UTF8, "application/json")
            });
        }
Ejemplo n.º 2
0
        public static HttpResponseMessage title(HttpRequestMessage req,
                                                [HttpTrigger] TitleRequest parameters,
                                                [SQLDatabase(ConnectionString = "ConnectionString",
                                                             SQLQuery = "SELECT * FROM Book WHERE Title LIKE CHAR(37)+'{title}'+CHAR(37)")]
                                                DataTable table,
                                                TraceWriter log)
        {
            log.Info("title|DataTable: C# HTTP trigger function processed a request.");

            // Convert data table to JSON string

            var objType = JArray.FromObject(table, JsonSerializer.CreateDefault(new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));                                                                                                                                               //.FirstOrDefault(); // Get the first row
            var js = objType.ToString();

            return(new HttpResponseMessage(HttpStatusCode.OK)
            {
                StatusCode = HttpStatusCode.OK,
                Content = new StringContent("{ \"Data\": " + js + " }", Encoding.UTF8, "application/json")
            });
        }