Create an index on a property in a list

6 views
Skip to first unread message

Zzz

unread,
Sep 8, 2011, 6:01:42 AM9/8/11
to NoRM mongodb
Hi All,

In the NoRM unit tests I see an index to do this:

prods.CreateIndex(j => new { j.Available, j.Inventory.Count },
"complexIndex", true, IndexOption.Ascending);

Where Inventory is of type List<InventoryChange>.

Now, in my situation I really need to create an index on a specific
property of a List of objects. So for example I need to create an
index on InventoryChange.CreatedOn.

This is supported in MongoDB by doing the following:

db.TestProduct.EnsureIndex({"InventoryChange.CreatedOn" : 1});

However in NoRM syntax I cannot find an equivalent. Am I missing
something? Is there some way to do it?

Thanks in advance!!!

Zzz

unread,
Sep 8, 2011, 6:03:25 AM9/8/11
to NoRM mongodb
Sorry I had a typo on the MongoDB syntax, this would something along
the lines of:

db.TestProduct.EnsureIndex({"Inventory.CreatedOn" : 1});
Reply all
Reply to author
Forward
0 new messages