//maps
docs.Tenants.Select(tenant => new { TenantId = tenant.__document_id, Name = tenant.Name, IsActive = tenant.IsActive, TotalUsers = 0})
//maps
docs.HierarchicalUserAccounts.Select(user => new { TenantId = (DynamicEnumerable.FirstOrDefault(user.Claims, x => x.Type == "tenant_id")).Value, Name = (this.LoadDocument((DynamicEnumerable.FirstOrDefault(user.Claims, x => x.Type == "tenant_id")).Value)).Name, IsActive = false, TotalUsers = 1})
//reduce
results.OrderBy(result => result.Name).GroupBy(result => new { TenantId = result.TenantId, Name = result.Name}).Select(g => new { TenantId = g.Key.TenantId, Name = g.Key.Name, IsActive = Enumerable.Any(g, x => x.IsActive), TotalUsers = Enumerable.Sum(g, x => ((int) x.TotalUsers))})
{
"Name": "tenant100",
"Licenses": 100,
"AdminId": "db08a33b-9a3f-4038-ae3d-dc3dc97318fa",
"IsActive": false,
"Applications": [
"csCM",
"csIM",
"csRA",
"csP&P",
"csGlobal"
],
"LogoUrl": null
}{
"Name": "some test tenant",
"Licenses": 10,
"AdminId": "e50ea0cc-10ef-432e-96d5-260173f86916",
"IsActive": true,
"Applications": [
"csCM",
"csIM",
"csRA",
"csP&P",
"csGlobal"
],
"LogoUrl": null
}Hibernating Rhinos Ltd
Oren Eini l CEO l Mobile: + 972-52-548-6969
Office: +972-4-622-7811 l Fax: +972-153-4-622-7811
--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
FirstOrDefault is always wrong. Stop using it.
FirstOrDefault is always wrong. Stop using it.I agree, but this sample was from Oren so that's what I used. in any case it doesn't really explain how the null was passed as the item exists in the collection (always) and is never null
Hibernating Rhinos Ltd
Oren Eini l CEO l Mobile: + 972-52-548-6969
Office: +972-4-622-7811 l Fax: +972-153-4-622-7811
--