NoRM and Geospatial on Nested Collections

9 views
Skip to first unread message

MauricioS

unread,
Sep 7, 2011, 1:02:17 PM9/7/11
to NoRM mongodb
Hello I use NoRM for managing Mongo, but I am wondering if it is
possible to apply and use 2d indexing with it. I have followed the
recommendations on this page
http://groups.google.com/group/norm-mongodb/browse_thread/thread/f6623652ffc96386?fwc=1
However I want to know how to use it with a nested collection that
contains an array of coordinates, so the code looks like this:

public class MainCollection : ModelBase
{
public string Type { get; set; }
public List<Criteria> CriteriaList { get; set; }
}

public class Criteria
{
public double[] Coordinates { get; set; }
}

I am using a NoRM Repository pattern, so I can do a query like:

var query = _mainCollectionRepository.Find(p => p.Type == "MyType");

If I had the coordinates array inside the MainCollection, I could
easily geo query MainCollection, but how can I query using the nested
List<t> ?

Thanks in advance for all the help.

Mauricio S.

Zzz

unread,
Sep 8, 2011, 6:09:16 AM9/8/11
to NoRM mongodb
If I'm understanding your question correctly this should be supported
with the LINQ provider. Something along the lines of (not tested):

GetCollection<MainCollection>().AsQueryable().Where(mc =>
mc.CriteriaList.Any(cl => cl.Coordinates.Any(c => c == [insert
coordinate here])))

On Sep 7, 6:02 pm, MauricioS <msanche...@gmail.com> wrote:
> Hello I use NoRM for managing Mongo, but I am wondering if it is
> possible to apply and use 2d indexing  with it. I have followed the
> recommendations on this pagehttp://groups.google.com/group/norm-mongodb/browse_thread/thread/f662...
Reply all
Reply to author
Forward
0 new messages