Skip to content

Instantly share code, notes, and snippets.

@dj-nitehawk
Created March 16, 2020 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dj-nitehawk/5d36e976ef3b1e5f598947b0b34aa279 to your computer and use it in GitHub Desktop.
Save dj-nitehawk/5d36e976ef3b1e5f598947b0b34aa279 to your computer and use it in GitHub Desktop.
find records that matches a nested array element
using MongoDB.Entities;
using MongoDB.Entities.Core;
using System;
using System.Linq;
namespace StackOverFlow
{
public class AutoSave : Entity
{
public string[] Templates { get; set; }
}
public static class Program
{
private static void Main()
{
new DB("test", "localhost");
var guids = new[] {
Guid.NewGuid().ToString(),
Guid.NewGuid().ToString()
};
new AutoSave { Templates = guids }.Save();
var result = DB.Queryable<AutoSave>()
.Where(s => s.Templates.Contains(guids[1]))
.ToList();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment