influxdb-client-csharp icon indicating copy to clipboard operation
influxdb-client-csharp copied to clipboard

Write Error when initializing auto-properties

Open cklenk opened this issue 2 years ago • 2 comments
trafficstars

Steps to reproduce:

  1. Set up measurement table with auto props with inline default values
  2. Write query by POCO
  3. Error

Expected behavior: Able to write to measurement

Actual behavior: Got error says unable to determine measurement. Does it have a InfluxDB.Client.Core.Measurement or IsMeasurement InfluxDB.Client.Core.Column attribute?

Specifications:

  • Client Version: 4.13.0
  • InfluxDB Version: 1.7
  • Platform: Linux

cklenk avatar Oct 09 '23 19:10 cklenk

Hi @cklenk,

Thank you for using our client. Could you share some code that reproduces the exception you're encountering?

Regards

bednar avatar Oct 10 '23 03:10 bednar

Hi @cklenk,

Thank you for using our client. Could you share some code that reproduces the exception you're encountering?

Regards

Yes, sure thing! Here is some code snippet. I think it should give you the gist of the problem. If I remove the default vars on the AlgoData class, the write works fine. Otherwise, I get that error. It's not a big deal, I have a method that will init the vars for me, but I do like to do it in 1 line on the class if possible.

[Measurement("AlgoTable")] class AlgoData { [Column("DeviceId", IsTag = true)] public string DeviceId { get; set; } [Column("input")] public double InputTemp { get; set; } [Column("output")] public double OutputTemp { get; set; } [Column("peakValue")] public int PeakValue { get; set; } = 0; [Column("runningState")] public int RunningState { get; set; } = 2; [Column("signal")] public int Signal { get; set; } = 0; [Column(IsTimestamp = true)] public DateTime TimeStamp { get; set; } } async void InsertAlgoData(List<AlgoData> algoResults) { using (InfluxDBClient client = GetClient(100)) { try { // Write the measurement to database await client.GetWriteApiAsync().WriteMeasurementsAsync(algoResults, WritePrecision.Ns); } catch (Exception ex) { Exceptions.LogException(ex); } } } InfluxDBClient GetClient(double timespanSeconds = 10) { var options = new InfluxDBClientOptions(url: "localhost") { Timeout = TimeSpan.FromSeconds(timespanSeconds), LogLevel = LogLevel.Basic, Org = "123", Bucket = "XX" }; return new InfluxDBClient(options); }

cklenk avatar Oct 10 '23 17:10 cklenk