expression

MongoDB expression to query array of subdocuments

时光总嘲笑我的痴心妄想 提交于 2019-12-24 10:56:42
问题 I am building an application using MongoDB 4 / Mongoose 5. I have a collection 'records' with an array of subdocuments 'Items'. { RecordID: 1, Items: [ { Title: 'Example Title 1', Description: 'Example Description 1', }, { Title: 'Example Title 2', Description: 'Example Description 2', } ] } I am building a dynamic query generator that creates MongoDB expression operators based on a UI query builder. The dynamic query builder is building the MongoDB expressions correctly. However, the

Parse Parenthesis as atoms ANTLR

帅比萌擦擦* 提交于 2019-12-24 10:19:59
问题 I'm trying to match balanced parentheses such that, a PARAMS tree is created if a match is made, else the LPARAM and RPARAM tokens are simply added as atoms to the tree... tokens { LIST; PARAMS; } start : list -> ^(LIST list); list : (expr|atom)+; expr : LPARAM list? RPARAM -> ^(PARAMS list?); atom : INT | LPARAM | RPARAM; INT : '0'..'9'+; LPARAM : '('; RPARAM : ')'; At the moment, it will never create a PARAMS tree, because in the rule expr it will always see the end RPARAM as an atom,

Expression evaluator for C#/Python/Ruby

我的未来我决定 提交于 2019-12-24 09:52:34
问题 We have semi-complicated expressions in the format: "25 + [Variable1] > [Variable2]" We need an expression evaluator to parse the expression and use a callback to ask for the variable values and work out the overall result of the expression. It has to be a callback as there are thousands of variables. We need the usual math operators but also things like "if" etc. The richer the language the better. We can use any language we want. Anyone have any suggestions? 回答1: Check out NCalc. It's .NET

SELECT query to return a row from a table with all values set to Null

这一生的挚爱 提交于 2019-12-24 09:52:07
问题 I need to make a query but get the value in every field empty. Gordon Linoff give me the clue to this need here: SQL Empty query results which is: select t.* from (select 1 as val ) v left outer join table t on 1 = 0; This query wors perfectly on PostgreSQL but gets an error when trying to execute it in Microsoft Access, it says that 1 = 0 expression is not admitted. How could it be fixed to work on microsoft access? Regards, 回答1: If the table has a numeric primary key column whose values are

Adding `MethodCallExpression` on top of provided `Expression`

廉价感情. 提交于 2019-12-24 09:39:45
问题 I'm having expression tree originating in Linq, e.g. leCollection.Where(...).OrderBy(...).Skip(n).Take(m) . Expression looks like: Take(Skip(OrderBy(Where(...), ...), n), m) // you got the idea Now, this is my ideal state that I have Take and Skip there, but it is not the rule. I would like to add Take / Skip programmatically if needed. I came up with way how to change Take / Skip argument, and I'm even able to add Skip under Take if I detect it's not present, but I'm struggling to figure out

iOS DDMathParser Get Number 'Blocks'

可紊 提交于 2019-12-24 08:55:24
问题 I am building a calculator app for iOS using DDMathParser. I would like to know how to separate an expression ( NSString ) like 5+900/32 into its individual number values: 5 , 900 , and 32 . I would prefer that I get these in an NSArray or other relatively useful list object. I have heard that there is an easy way to do this with DDMathParser - It's why I switched from GCMathParser . 回答1: DDMathParser author here. Yes, this is very easy, and there are a couple of ways to go about it. If you

How to render expressions in matlab gui?

僤鯓⒐⒋嵵緔 提交于 2019-12-24 07:35:12
问题 I want to convert mathematical expressions from a string in LaTeX format to their neat form. My initial solution was using another program to convert string to image and loading the image in gui. Is there such program or Matlab function (that gets a latex string as input and creates an image that can be loaded in Matlab)? or is there any better way? 回答1: look at text command and it's 'Interpreter' property - it can be set to 'Latex' and provide you with the functionality you want. (see last

c# linq MethodCallExpression for Sum( DataRow) used for .GroupedBy().Select()

百般思念 提交于 2019-12-24 07:04:18
问题 I programmed the following query which selects the grouped data key columns and sums the Amount column. It works perfect. private static IEnumerable<GroupSum> GetListOfGroupedRows(IEnumerable<IGrouping<GroupKey, DataRow>> queryGroup) { IEnumerable<GroupSum> querySelect = queryGroup .Select(g => new GroupSum { KeyS0 = g.Key.KeyS0, KeyS1 = g.Key.KeyS1, AggN0 = g.Sum(row => row.Field<double>("Amount")) }); return querySelect; } The query uses the following types to group and sum. private class

Common filtering logic in WCF query interceptors using interface

徘徊边缘 提交于 2019-12-24 06:22:49
问题 The classes in my data model implement an interface: public class SomeType : ISomeInterface public interface ISomeInterface In my WCF query interceptors, I want to use a common Expression so that I can use the same filtering logic on multiple types: [QueryInterceptor("SomeType")] public Expression<Func<SomeType, bool>> SomeTypeInterceptor() { // Return CommonFilter() or extend it with logic unique to SomeType } private Expression<Func<ISomeInterface, bool>> CommonFilter() { // Use

Common filtering logic in WCF query interceptors using interface

流过昼夜 提交于 2019-12-24 06:22:13
问题 The classes in my data model implement an interface: public class SomeType : ISomeInterface public interface ISomeInterface In my WCF query interceptors, I want to use a common Expression so that I can use the same filtering logic on multiple types: [QueryInterceptor("SomeType")] public Expression<Func<SomeType, bool>> SomeTypeInterceptor() { // Return CommonFilter() or extend it with logic unique to SomeType } private Expression<Func<ISomeInterface, bool>> CommonFilter() { // Use