0
InitializeComponent();
var connectionString = "mongodb://localhost:27017";
var client = new MongoClient(connectionString);
var database = client.GetDatabase("test");
var collection = database.GetCollection<Rootobject>("container");
var res = collection.Aggregate().Group(x => x._event.NodeId, x => new { Name = x.Key, WTs = x.Select(r => r._event.WT).ToList() }).ToList();
cartesianChart1.Series = new SeriesCollection
{
new LineSeries
{
Title = res["event"]["NodeId"] ,
Values = new ChartValues<double> {4.0, 3.9, 3.9, 3.85, 3.8, 3.8, 3.75}
},
}
上記のコードは、私のグラフ入力にmongodbを使用しようとしています。しかし、まず私はMongoDBからクエリできるようにする必要があります。私はvarレコードを考え出しましたが、 'NodeId'にはまだエラーがあります。それはEvent[] does not contain a definition for 'NodeID' and no extension method 'NodeId' accepting a first argument of type Event[]
です。定義違反のクラスでエラーが発生しました
.Group(x => x._event.NodeId
あなた_event
プロパティはEvent
の配列であるタイプEvent[]
、である:以下は私の公共のクラス
public class Rootobject
{
public string _id { get; set; }
public Header[] header { get; set; }
public Event[] _event { get; set; }
}
質問を破らないでください。 –