Take the community feedback survey now.

Jonas Bergqvist
Jan 31, 2011
  4277
(0 votes)

New features in Dynamic Data Store (DDS)

Working on the “LinqToDDS” project is the most fun I’ve ever had at work. Therefore, it’s a pleasure to announce new LINQ support in the R2 wave.

Earlier we only supported the deferred execution methods “ToList()”, “ToArray”, “ToDictionary”, “ToLookup”, and “Count”. In the R2 wave, we have added the support for “First”, “FirstAndDefault”, “Single”, “SingleOrDefault”, “Last”, and “LastOrDefault”. We have also added support for multiple group by, “contains” on .Net collections, and predicate support on “count”.

Single object support

When developers used the LINQ support to query DDS for only one object, they had to make a query like “.ToList().First()”. This isn’t only ugly, it’s also inefficient. This query receives all identities matching the query, and puts them into memory. Then it takes the first item from memory, and query the database for the inline properties for that item (if the object is in the cache, it will be received from the cache).

Now, we’ve added support for “First”, “FirstOrDefault”, “Single”, “SingleOrDefault”, “Last”, and “LastOrDefault”. All of those both with and without predicates.

Fist and Last

When making a query directly against “First” (same with “Last”), the database will only receive the inline properties for the first/last object matching the query, and therefore we have everything needed to recreate the object for you.

Single

When making a query against “Single” we will do the same as for “First” and “Last”, but we will try to receive the two first objects matching the query instead of one. If we receive two objects, we throw an exception, because this is what you should used “Single” for.

Defaults

When using “FirstOrDefault”, SingleOrDefault”, or “LastOrDefault”, we will return default(T) if the query didn’t receive any result from the database. For “First”, “Single”, and “Last” an exception will be thrown if no result was received.

Multiple group by support

Earlier we only had support for grouping on one property. This could be a problem if you for example want to sum number of visits on a page for a specified group. Than, page and group should be grouped to get sum of visits for the rows where page and group are the same.

Now, this is possible. A query could look like:

var groupedQuery = GetStore().Items<MyClass>()
.GroupBy(myClass => new { Page = myClass.PageId, Group = myClass.AccessGroup })
.Select(grouped => new { Page = grouped.Key.Page, Group = grouped.Key.Group, Hits = grouped.Sum(s => s.Visits) });

Contains on .Net Collection

If you have a .Net list and wants to check if a property in the DDS has the same value as any of the items in the list, we now have support for that.

var myList = new List<string>();
myList.Add("Jonas");
myList.Add("Erik");
myList.Add("Per");
var query = GetStore().Items<MyClass>()
.Where(p => myList.Contains(p.FirstName));

Count with predicate

In the earlier versions, it wasn’t possible to use predicates in the “Count” deferrer. This is now fixed.

var query = GetStore().Items<MyClass>().Count(p => p.LastName == "Bergqvist");
Jan 31, 2011

Comments

Please login to comment.
Latest blogs
A day in the life of an Optimizely OMVP - Opticon London 2025

This installment of a day in the life of an Optimizely OMVP gives an in-depth coverage of my trip down to London to attend Opticon London 2025 held...

Graham Carr | Oct 2, 2025

Optimizely Web Experimentation Using Real-Time Segments: A Step-by-Step Guide

  Introduction Personalization has become de facto standard for any digital channel to improve the user's engagement KPI’s.  Personalization uses...

Ratish | Oct 1, 2025 |

Trigger DXP Warmup Locally to Catch Bugs & Performance Issues Early

Here’s our documentation on warmup in DXP : 🔗 https://docs.developers.optimizely.com/digital-experience-platform/docs/warming-up-sites What I didn...

dada | Sep 29, 2025

Creating Opal Tools for Stott Robots Handler

This summer, the Netcel Development team and I took part in Optimizely’s Opal Hackathon. The challenge from Optimizely was to extend Opal’s abiliti...

Mark Stott | Sep 28, 2025

Integrating Commerce Search v3 (Vertex AI) with Optimizely Configured Commerce

Introduction This blog provides a technical guide for integrating Commerce Search v3, which leverages Google Cloud's Vertex AI Search, into an...

Vaibhav | Sep 27, 2025

A day in the life of an Optimizely MVP - Opti Graph Extensions add-on v1.0.0 released

I am pleased to announce that the official v1.0.0 of the Opti Graph Extensions add-on has now been released and is generally available. Refer to my...

Graham Carr | Sep 25, 2025