Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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