dynamic-linq

Counting percent of rows with category out of total number of rows using Dynamic Linq

假装没事ソ 提交于 2019-11-27 19:38:15
问题 How to achieve this using Dynamic Linq Join and Dynamic Linq SelectMany 回答1: Desired result is in q and q2. q shows combination of aggregates from different levels of grouping in one expression. q2 uses calculated agg from prev levels and generates shorter SQL query. var grp=(db.A as IQueryable).GroupBy("grp","it"); var grp2=grp.Select("new(key as key,new(count() as cnt) as agg)"); foreach(dynamic r in grp2) Console.WriteLine("grp:"+r.key+"\tcnt:"+r.agg.cnt); //foreach(dynamic r in grp)

Dynamic LINQ GroupBy Multiple Columns

心已入冬 提交于 2019-11-27 13:45:32
I need to translate the following LINQ query to Dynamic LINQ that accepts several grouping columns based on user input. Basically I have a bunch of dropdownlists that apply groupings and I don't want to enumerate every combination of groupings. If Dynamic LINQ fails, I may have to construct a SQL query manually, and nobody wants that. var grouping = ( from entry in ObjectContext.OmniturePageModules where entry.StartOfWeek >= startDate && entry.StartOfWeek <= endDate && ( section == "Total" || section == "All" || entry.Section == section ) && ( page == "Total" || page == "All" || entry.Page ==

Building Dynamic LINQ Queries based on Combobox Value

青春壹個敷衍的年華 提交于 2019-11-27 12:56:31
I have a combo box in Silverlight. It has a collection of values built out of the properties of one of my LINQ-to-SQL objects (ie Name, Address, Age, etc...). I would like to filter my results based off the value selected in a combo box. Example: Say I want everyone with a last name "Smith". I'd select 'Last Name' from the drop down list and enter smith into a textbox control. Normally I would write a LINQ query similar to... var query = from p in collection where p.LastName == textbox.Text select p; Is it possible to decide the property dynamically, maybe using Reflection? Something like var

Dynamic LINQ - Is There A .NET 4 Version?

人盡茶涼 提交于 2019-11-27 10:21:09
问题 I'm looking to use LINQ for some searching routines and wanted to have some dynamic where clauses. So, for example, if a user wants to search by city or search by state, I would have a dynamic LINQ Where<> call instead of creating two strongly typed LINQ expressions and then using the appropriate one based on how the user wants to search. So I would like to do this: String criteria="p.City='Pittsburgh'"; //or "p.State='PA'" personData.Where(criteria) instead of personData.Where(p => p.City==

Is Injection Possible through Dynamic LINQ?

你。 提交于 2019-11-27 07:33:22
Using the Dynamic LINQ library ( link ), is it vulnerable to injection? and (if so) how can this be protected against? Some background from Security Considerations (Entity Framework) : LINQ to Entities injection attacks: Although query composition is possible in LINQ to Entities, it is performed through the object model API. Unlike Entity SQL queries, LINQ to Entities queries are not composed by using string manipulation or concatenation, and they are not susceptible to traditional SQL injection attacks. Since Dynamic SQL is composed using strings does that mean that it might be susceptible to

How do I do a left outer join with Dynamic Linq?

≡放荡痞女 提交于 2019-11-27 07:27:16
I am trying to mimick the left outer join here but using dynamic linq extension methods. What i have: public static IQueryable SelectMany(this IQueryable source, string selector, string resultsSelector, params object[] values) { if (source == null) throw new ArgumentNullException("source"); if (selector == null) throw new ArgumentNullException("selector"); // Parse the lambda LambdaExpression lambda = DynamicExpression.ParseLambda( source.ElementType, null, selector, values); // Fix lambda by recreating to be of correct Func<> type in case // the expression parsed to something other than

Dynamic LINQ GroupBy Multiple Columns

纵然是瞬间 提交于 2019-11-27 04:04:51
问题 I need to translate the following LINQ query to Dynamic LINQ that accepts several grouping columns based on user input. Basically I have a bunch of dropdownlists that apply groupings and I don't want to enumerate every combination of groupings. If Dynamic LINQ fails, I may have to construct a SQL query manually, and nobody wants that. var grouping = ( from entry in ObjectContext.OmniturePageModules where entry.StartOfWeek >= startDate && entry.StartOfWeek <= endDate && ( section == "Total" ||

Sortable JqGrid using LINQ to MySQL (DbLinq) and Dynamic LINQ - Orderby doesn't work

我的未来我决定 提交于 2019-11-27 02:03:22
I've got problem with sorting entries in JqGrid. Orderby seem to not work. I set breakpoint in code and I noticed, that orderby doesn't change order of elements. Any idea what could be wrong? I'm using LINQ to SQL with MySQL (DbLinq project). My action code: public ActionResult All(string sidx, string sord, int page, int rows) { var tickets = ZTRepository.GetAllTickets().OrderBy(sidx + " " + sord).ToList(); var rowdata = ( from ticket in tickets select new { i = ticket.ID, cell = new String[] { ticket.ID.ToString(), ticket.Hardware, ticket.Issue, ticket.IssueDetails, ticket.RequestedBy, ticket

Entity Framework + DayOfWeek

我的梦境 提交于 2019-11-26 23:31:30
问题 Using the System.Linq.Dynamic (managed here https://github.com/kahanu/System.Linq.Dynamic ), I am trying to capture the DayOfWeek field found on the DateTime for aggregation purposes using Entity Framework 6 (or greater). Previously asked for something similar, which helped a lot, Dynamic Linq + Entity Framework: datetime modifications for dynamic select Entity Framework supports getting the DayOfWeek using the SqlFunctions.DatePart("dw", datetime?) or we could do something a little more

Building Dynamic LINQ Queries based on Combobox Value

北战南征 提交于 2019-11-26 18:14:22
问题 I have a combo box in Silverlight. It has a collection of values built out of the properties of one of my LINQ-to-SQL objects (ie Name, Address, Age, etc...). I would like to filter my results based off the value selected in a combo box. Example: Say I want everyone with a last name "Smith". I'd select 'Last Name' from the drop down list and enter smith into a textbox control. Normally I would write a LINQ query similar to... var query = from p in collection where p.LastName == textbox.Text