Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
387 views
in Technique[技术] by (71.8m points)

Azure stream analytics with a c# udf that returns a list of objects

I have a IOT device that has a data payload of a string of hex characters. Azure event-hubs is providing input for my azure stream analytics. I am using a c# udf to return a list of objects and would like to save them to a DB using one of my outputs. It will always have 4 records.

However I can't get the SQL type syntax correct. The udf is running and returning the results correctly but I haven't got the syntax correct to pass them to my output. Currently only one record is created in my TempHum output and it has all null values.

with results as (
    select udf.process_UDF_TempHum(data,time,device_id)
    from hub

)


SELECT
    device_id, data, time
INTO
    DB
FROM
    hub

Select process_UDF_TempHum.Humidity, process_UDF_TempHum.Temperature, process_UDF_TempHum.DateTime, process_UDF_TempHum.DeviceID


into
    TempHum

from
    results

UDF

namespace process
{
    public class TempHum
    {
        public int Temperature { get; set; }
        public int Humidity { get; set; }
        public DateTime DateTime { get; set; }
        public int DeviceID { get; set; }
    }

    public class UDF
    {
        public static List<TempHum> TempHum(string data, string time, string device_id)
        {
            var results = new List<TempHum>();
 

            for (int i = 0; i < 4; i++)
            {

                var TH = new TempHum();

                TH.Temperature = 10
                TH.Humidity = 10              
                TH.DeviceID = 1;
                TH.DateTime = DateTime.Now;
                results.Add(TH);
            }


            return results;
        }

    }
}
question from:https://stackoverflow.com/questions/65934683/azure-stream-analytics-with-a-c-sharp-udf-that-returns-a-list-of-objects

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...