logo
down
shadow

Projection after Group


Projection after Group

By : user3099054
Date : January 11 2021, 03:26 PM
I wish this help you SOLVED:
I solved the problem just casting the List to a List of NestedArrayObject.
code :
var return= db.Set<DataBaseObject>(CollectionName)
              .Aggregate()
              .Match(doc => doc.Id.Equals(id))
              .Group(doc => doc.Id, g => new
              {
                  Id = g.Key,
                  nestedArray = g.Select(x => new 
                  {
                      x.name,
                      x.cars
                  })
              })
              .Project(model => new ProjectObject
              {
                  externalId = model.Id,
                  nestedArray = (List<NestedArrayObject>) model.nestedArray.Select(pv => new
                 {
                      pv.name,
                      cars = pv.cars.Where(a=>a.new\)
                  })
              }).FirstOrDefault();


Share : facebook icon twitter icon
With EF, when you group by, is that a projection? How to get joined columns

With EF, when you group by, is that a projection? How to get joined columns


By : robcalewar
Date : March 29 2020, 07:55 AM
Hope that helps
So when I group by, it seems I have to use the 'into' keyword which I guess does some sort of projection?
code :
from u in context.users
join a in context.addresses on u.UserId equals a.UserId
select new { u, a } into ua
join p in context.points on ua.u.UserId equals p.UserId into points
select new
{  
   ua.u.Username,
   ua.u.CountryCode, // need for grouping by country
   ua.a.address1,
   Points = points.Sum()
} 
// last grouping by country. You can omit it
into x
group x by x.CountryCode into g
select g;
Hibernate query fails with "this_.id must appear in GROUP BY" when using projection.count or projection.rowcou

Hibernate query fails with "this_.id must appear in GROUP BY" when using projection.count or projection.rowcou


By : mdapires
Date : March 29 2020, 07:55 AM
wish of those help I've identified the solution to this.
What I really needed was a Hibernate equivalent of SELECT count(*) FROM (SELECT ... ) Per https://docs.jboss.org/hibernate/orm/4.2/manual/en-US/html/ch16.html#queryhql-subqueries, this is not allowed in HQL. Also, based on https://docs.jboss.org/hibernate/orm/4.2/manual/en-US/html/ch17.html#querycriteria-detachedqueries, it appears that legacy Hibernate Criteria does not support this function either, since the way of creating subqueries there is to use DetachedCriteria adding these via the Subqueries class. It does appear to be doable using formal JPA CriteriaBuilder per http://docs.jboss.org/hibernate/orm/4.2/devguide/en-US/html/ch12.html#querycriteria-from, however due to the architecture currently employed in my service, I am unable at this time to use this feature.
Dynamic mongo projection - a projection that uses a field in the document to determine the projection

Dynamic mongo projection - a projection that uses a field in the document to determine the projection


By : Cormac Cotter
Date : March 29 2020, 07:55 AM
help you fix your problem Unfortunately this is not available yet as part of the aggregation framework. However, according to this JIRA ticket, it is currently "planned by not scheduled". The only way of doing this currently is by using the map/reduce functionality. If you want to go ahead and use that, it would mean doing something as follows:
Map each document by _id and emit the appropriate key. Since there will be only one value per key, the reduce function will not get called, but you still need to initialise the variable you use for the reduce function. You can use an empty function or an empty string. Run map/reduce, saving the results in a collection of your choice.
code :
var mapper = function() {
    var typeValue = this.types[this.default];
    emit(this._id, typeValue);
};
var reducer = "";

db.types.mapReduce(mapper, reducer, { out : "results" } );
> db.results.find();
{ "_id" : ObjectId("53d21a270dcfb83c7dba8da9"), "value" : 1 }
var mapper = function() {
    var typeValue = this.types[this.default],
        typeKey = "types." + this.default;

    emit(this._id, { key : typeKey, val : typeValue } );
};   
> db.results.find().pretty();
{
    "_id" : ObjectId("53d21a270dcfb83c7dba8da9"),
    "value" : {
        "key" : "types.x",
        "val" : 1
    }
}
variable 'x' in projection not present in GROUP BY

variable 'x' in projection not present in GROUP BY


By : Musaddif Mahmood
Date : March 29 2020, 07:55 AM
I hope this helps you . In SPARQL, every query that uses an aggregate function (such as COUNT, SUM, SAMPLE, etc.) always uses a grouping. Even if you do not explicitly specify a GROUP BY clause in your query, it uses the 'default grouping' (that is, a single group to which all solutions belong).
In a SPARQL query which uses aggregates, non-aggregated variables (such as ?region_name) may not be projected in the SELECT clause, unless they are explicitly added to the grouping.
code :
SELECT ?region_name (COUNT(?municipality) AS ?count)
WHERE {
  ... 
}
GROUP BY ?region_name 
Linq Group by With projection into a list

Linq Group by With projection into a list


By : André Matias
Date : March 29 2020, 07:55 AM
this will help I'm trying to group by an object and project it into a list in such a way that each element of a list property generates a projected object in this new list. , You should change a bit the logic of the .Select over the group:
code :
var result = nonEuTranslationRequests
            .GroupBy(i => i.TranslationSource.Language)
            .Select(g => g.SelectMany(r => r.TargetLanguages).Select(i => new {
                g.Key.Language,
                TargetLanguage = i
            })
            .ToList();
Related Posts Related Posts :
  • Passing enum type to Converter with integer value
  • Pool of objects with objects that are already on the scene in advance
  • StatusBar text fade-out when binding using Caliburn.Micro
  • Queryfilter on ApplicationUser in OnModelCreating in ApplicationDbContext creates StackOverflowException
  • How to get record form a different table based on a value from first table with linq expression?
  • Show data in Grid from returned model
  • Using Attributes to Override Data Model Conventions
  • Basic OOP console calculator, result Error
  • Compositon and Repository pattern
  • Multiple using statements with if condition
  • How do i increase a number by 1 in every line that contain the number 1
  • Add binding to elements that are created in codebehind
  • How to add a column in an existing AspNetUsers table
  • Order a list of elements with another list of doubles
  • How to setup a NuGet package to copy content files to output build directory?
  • In SignalR Core using ChannelWriter: Do I need to call TryComplete twice if there's an exception?
  • C# GetProcessesByName: issue with colon
  • c# wpf | create complex object with user-defined name to Serialize into JSON
  • How can I get a instance of a generic list with reflection?
  • WPF XAML - Design time and visibility of textbox
  • EF Core and MySql query is too slow
  • Getting Registered App Display Name from an App Id
  • How to get all variables from a string
  • Delete entity with all childs connected
  • Azure Build agent cant´t find class library referance
  • Initialize Nested Dictionaries in c#
  • .Net Core Binding
  • Loading a pop up page in ASP.net through a js file
  • How to pass alert or notification message from controller to View?
  • C# to pause, turn on ssas server, backup cube.... how to?
  • How to execute DataTable.Select() for a column of custom class type for a particular element in that C#
  • how to connect mysql8.0 with C#
  • Passing incorrect values into MultiValueConverter by MultiBinding
  • Can i use IEnumerator as Update func?
  • How to convert API Json response to C# Array?
  • Blazor Textfield Oninput User Typing Delay
  • Performing both layout and render transform results in wrong output
  • uwp beforetextchanged cursor moving in front of text
  • How to keep duplicates from a string[] exclude words from a List and print them out
  • .Net Core Strings.Asc/Mid/Chr/Len missing even after importing Microsoft.VisualBasic
  • How to return to previous search page without being asked to Confirm Form Re-submission and keeping the results on ASP.N
  • How set a identity scaffolding item/page how initial page in asp.net MVC core?
  • LINQ isn't calling Dispose on my IEnumerator when using Union and Select, expected behavior or bug?
  • What is "ByteArray.uncompress()" in AS3 equivalent to in C#?
  • Getting a specific letter from a string variable for my simple guessing game for clues
  • Send an email with Outlook without a subject --- dialog box issue
  • passing List<MyModel> from my controller in the "WebInterfaceProject" to the processor method in "D
  • How to convert Word document created from template by OpenXML into MemoryStream?
  • How can I make a single slider that changes the color of an object?
  • Remap JSON parameter in c#
  • What is the difference between "this ref" and "ref this" when talking about C# 7.2 ref extension met
  • Convert OpenSSL encryption into native C#
  • Accessing Properties in Razor Pages
  • How to get SOAP element value
  • C# error cannot convert sytem.text.regularexpressions.match to string
  • Issues with Save/Load System in a Text Based Adventure game made with ScriptableObjects in Unity
  • VS2019 MSBuild.exe - ASP .Net MVC project fails to publish when using PublishProfile, but works when using OutDir parame
  • Does <pages validateRequest="false" /> in Web.config still matter?
  • How to send new request to redirect URL with new access token
  • Attempt to invoke virtual method on a null object reference Xamarin LockScreen
  • shadow
    Privacy Policy - Terms - Contact Us © festivalmusicasacra.org