efcore icon indicating copy to clipboard operation
efcore copied to clipboard

Cosmos: translate indexing into collection

Open roji opened this issue 4 years ago • 4 comments

_ = await ctx.Blogs.Where(b => b.Posts[2].Name == "foo").ToListAsync();

Note that since we support primitive collections, this should translate on those too.

roji avatar Aug 25 '21 10:08 roji

Related: https://github.com/dotnet/efcore/issues/16926

AndriySvyryd avatar Aug 27 '21 01:08 AndriySvyryd

Really love this package, but without this key feature (and other array functionality), I am very limited and will just have to go back to using the SDK for now

dalokey avatar Mar 29 '22 02:03 dalokey

Really love this package, but without this key feature (and other array functionality), I am very limited and will just have to go back to using the SDK for now

So because I really enjoy using this package, I wouldn't/couldn't go back to just using the SDK lol. Anyway, I kind of went my own way (and wouldn't expect this to be the best approach) to allow me to switch between EF and the SDK (until all the features I require are available on EF).

I realised that EF comes with a Database property that has already set the connection using EF's services.AddDbContextFactory().

So I managed to allow the context to give me a container (without having to do as much work as I would ever do using the SDK) by adding a public property on the defined DbContext class that has a singleton getter (no setter) to get the container :)

Database.GetCosmosClient().GetContainer("dbName", "containerName");

This would mostly likely be used for complex queries, not having any issues with commands atm.

Would love to not have to go this way, but I don't want to write SQL code to get around this.

dalokey avatar Mar 30 '22 09:03 dalokey

Note from triage: also consider other issues related to primitive collections--see label area-primitive-collections.

ajcvickers avatar Oct 26 '22 10:10 ajcvickers