score:0
Accepted answer
var grouping = Linq.Expr((Report_Data g) => new {g.Month, Option1 = g.prop1, Option2 = g.prop2});
if (userParameter == "X") {
grouping = Linq.Expr((Report_Data g) => new {g.Month, Option1 = g.prop3, Option2 = g.prop4});
} else if(userParameter == "Y") {
grouping = Linq.Expr((Report_Data g) => new {g.Month, Option1 = g.prop5, Option2 = g.prop6});
}
Source: stackoverflow.com
Related Query
- How would I use an anonymous result type for an expression delegate for LINQ to SQL?
- How to handle casting delegate of anonymous type <T>, to delegate of T for use in Where<T>() method of an IEnumerable<T>
- Linq - How to collect Anonymous Type as Result for a Function
- How to create LINQ Expression Tree to select an anonymous type
- LINQ How to define a default type for use with ElementAtOrDefault Operator
- How use Long type for Skip in Linq
- Can I use an anonymous type for this Linq grouping?
- How I can pass the LINQ result anonymous type to another method?
- How to use Expression for Linq union and intersect?
- How to make a return type for a result set in LINQ
- Use anonymous type for LINQ based lists instead of var
- How to use Linq or Lambda to join 1-to-many tables and project flattened results into an anonymous type
- How can I use Linq expression for Join with GroupBy in EF Core 3.1
- How to use the vb equivalent of ++ for an index property in a Linq query projecting a new type
- How to convert a list of anonymous object to string array using linq for return using Json Result in ASP.NET MVC
- Multiple input anonymous function to expression for use in LINQ
- C# : How to get anonymous type from LINQ result
- How to join two tables in linq and not get anonymous type result set
- How to execute a linq query for each item in a list , use it in the where clause and return a collection from the result of each query?
- How can i use Linq expression for Join on multiple table in EF Core 3.1
- How can I check null and assign new value in linq anonymous type to select expected sql result
- Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type
- What are Expression Trees, how do you use them, and why would you use them?
- How to return anonymous type from c# method that uses LINQ to SQL
- How does LINQ expression syntax work with Include() for eager loading
- How to use Expression to build an Anonymous Type?
- How would you write an Upsert for LINQ to SQL?
- C# re-use LINQ expression for different properties with same type
- How to use Dynamic LINQ (System.Linq.Dynamic) for LIKE operation?
- How do I use Linq for paging a generic collection?
More Query from same tag
- Linq query that return N results from two grouped columns
- Linq SelectMany include parent
- Get Flat Linked List from Table
- How to return Json as part of my view in C# MVC
- How to insert multiple rows of data from listview to linq to sql VB.Net
- ASP.NET Linq where filters checking dates not working
- Linq Query to Search "Many" in one to many relationship
- How to query the average from a certain property in an Entity and return it in a List of List of objects in LINQ?
- increment an integer via linq
- Is there a way of using orderby in a forloop C#?
- VB.NET SQL Server query to LINQ
- How to group LINQ to Entities results by enum and date?
- N-Ary/Multiple-List Cartesian Product
- Examples of VB.NET lambda expression
- IS there a better extension method than FindIndex to filter on a generic list?
- LINQ & XNode.DeepEquals running comparisons twice?
- Seeking recommendation for 3-tiered LINQ Query in Entity Framework
- Find top-level parent in List with LINQ
- Check if item exists in list and push value into it — in one shot
- Is there a suggested pattern for using LINQ between the Model & DataAccess Layers in a DDD based Layered Architecture
- At least one object must implement IComparable in Max()
- Joining items in a single List<>
- Custom Linq generator (AddDays) using NHibernate
- Entity Framework returning distinct records after join
- How to group a IQueryable by property 1 but order by property 2?
- Merge content of two tables with LINQ-to-SQL
- ASP.NET - Entity Framework - Only parameterless constructors and initializers are supported in LINQ to Entities
- Group By Contains [Date]
- How to implement Count method on Mocked IQueryable object
- Selecting object with collection of objects from many-to-many relationship