1

I'm storing Serilog logevents into ravenDb.

And now I trying to write a query where all documents with a specific "dynamic" propery should be returned.

Here is my query (don't work)

var logsWithRole = DataSession.Query<Serilog.Sinks.RavenDB.Data.LogEvent>()
          .Where(o => o.Properties.ContainsKey("Role")).ToList();

And this is an example of one of the documents in ravenDb I'm trying to query:

{
  "Timestamp": "2014-11-20T01:20:05.5095877+01:00",
  "MessageTemplate": "{Role}, {User} logged in",
  "Level": "Information",
  "Exception": null,
  "RenderedMessage": "True, \"Steve\" logged in",
  "Properties": {
    //this propery below (Role and it's value) I'm trying to get
    "Role": true,
    "User": "Steve"
  }
}

Just getting a NotSupportedException: Could not understand expression: .Where(o => o.Properties.ContainsKey("Role"))

What I'm I doing wrong here? Because of Serilogs structured logging features and the nuGet integrating it with RavenDb, some query like this must be able to be done on the Properties-object and it's objects and values inside?

user3228992
  • 1,373
  • 1
  • 16
  • 31

1 Answers1

1

Use:

          .Where(o => o.Properties["Role"] != null).ToList();
Ayende Rahien
  • 22,925
  • 1
  • 36
  • 41