C# - WPF UI To Allow User To Build A Complex Query And Output An Expression Tree
Dec 29, 2011
What I am about to do build is a UI that will allow a power user to build complex queries.
This is non-trivial, but very common. So before I re-invent the wheel, I would like to see if anybody can point me to some already-written free code or release some of their own.
Required:
To be able to specify some 'where-clause' type logic like this: Age>21 and (Citizen=True or HasGreeCard=True) but without having to type the query code, instead, use a UI with constrained options and on-the-fly syntax checking (e.g., no unclosed parenthesis or ending a term with an Operator).
I've seen this type of thing in many line-of-business apps, where you can say 'add condition' and another line appears on the UI like this:
Dropdown of fields Dropdown of ops (=, >, etc) Blank box for entry
And you can add more lines, and the lines are all and'ed, but you can also decide to OR a few, or insert parenthesis (explicity or via indenting), NOT a line, insert, delete, and move lines around, etc.
Not required but nice:
WPF - I could convert from winforms. Extensibility using OO constructs. Validate the sanity of the query. Emit a System.Linq.Expressions expression tree - or similar data structure. If it attempts to execute the query I don't need that; but I don't mind removing it.
View 1 Replies
ADVERTISEMENT
Sep 14, 2010
I have to join two main tables, and I need to filter the results by elements in an ASP.NET web form. These filters are created on the fly so I have to use a lot of where extensions to filter the query. I want to execute the query with as optimized SQL as possible.
I am first doing a simple join between TW_Sites and TW_Investigators. Then there are two sub-tables that are involved. TW_InvestigatorToArea and TW_InvestigatorToDisease. While most of the where clauses are working fine, I have found a performance issue that won't be an issue right now, but will be an issue as the table gets bigger.
The arrays DiseaseCategories and DiseaseAreas would be the results of a CheckBoxList result.
Protected Sub LoadResults()
'Get Dictionary of Filters
Dim FilterDictionary As OrderedDictionary = Session.Item("InvestigatorFilterDictionary")
' Initialize LinqToSql
[code]....
View 2 Replies
Nov 16, 2010
I have a product table which has around 90 columns in. Must of the columns are integers. When I search for an existing product and insert it into a row its fine but when I alter one of the columns and do an update using the command builder I get 'Expression Too Complex'. Does anyone know why this is happening and how to fix it?
View 4 Replies
Nov 19, 2009
So, I run a select statement in SQL and then it has something like " where clientName = 'John Doe' " I can generate a datagrid or dataset off the SQL statement, but it will only be good fro one client...... I would like to be able to populate a dataset/grid using the select satement and then having something like a combo box of names the USER can choose. Then the user selects the name and the datagrid is populated with that clients info or w/e........
[Code]....
View 2 Replies
Aug 17, 2009
I am trying to build a boggle solver, and this is the way I want to do it.I have a list of 52000 words.I want to Put them into a list as follows.A b c d e f g h i j k l m n o ..... z..Then for each letter, If possible, put each letter.Eg. under m a e i o u y or for q [code]i will look at "a" and then "av" and "ae" and "at" and check if further down the line there is a possibility. If not then I will abandon that line.How will I be able to build this tree database?
View 14 Replies
Feb 12, 2010
I have a hashing method whose operations depend on input to the function. Profiling the program has shown that too much time is spent evaluating this hash method. I want to try changing it into an expression tree, so the inner loop checks can be done once.
Here is a simplified version of the function (I undid some obvious optimizations for the example, and took out any input validation):
Private Function Checksum(ByVal inputValues As IEnumerable(Of UInt32),
ByVal declarations As IEnumerable(Of String),
ByVal statements As IEnumerable(Of String)) As UInt32
Dim variables = New Dictionary(Of Char, UInt32)
[code]....
I want to create a function which takes the declarations and statements and outputs a specialized expression tree representing a function which takes an IEnumerable of UInt32 and returns a UInt32.Follow-Up:I succeeded, and the speed-up was ridiculous (an order of magnitude). The main things I had to learn where:Use Expression.Lambda and Expression.Compile to get a delegate you can actually use.The Expression.Block factory method has a 'variables' parameter you (essentially) use to declare locals.Expression.lambda has 'parameters'.If you call Expression.Parameter twice, you're dealing with two different variables (even if their name is the same)! Store the result for later usage. Same for labels, etc.The result of a BlockExpression is the last expression in the block.
View 1 Replies
Oct 28, 2011
1) I am begginner to dynamic Linq and having serious trouble creating expression tree after WHERE
say.: items.Category_ID=4
I tried to construct it like: Dim products = From items In mydatacontent.Products
Dim AA As ParameterExpression = Expression.Parameter(GetType(String), "items")
Dim left1 As Expression = Expression.Property(AA, GetType(String).GetProperty("Category_ID")) here is the error Dim right1 As Expression = Expression.Constant("4") Dim BB As Expression = Expression.Equal(left1, right1)
[Code]...
View 2 Replies
Nov 21, 2010
Im getting some VB.Net Late binding operations cannot be converted to an expression tree. errors, have search here on the site and can only find solutions to the SQL get data code, not to my problem. The error "Late binding operations cannot be converted to an expression tree." At all my x.NAME) lines !? Im new to this so can anyone say me why i get this error..
[Code]....
View 1 Replies
Nov 19, 2010
I get this error "Late binding operations cannot be converted to an expression tree."
At all my x.NAME) lines !?
<div>Navn: <%: Html.EditorFor(Function(x) x.Name)%></div>
<h3>Adresse</h3>
<div>Linje 1: <%: Html.EditorFor(Function(x) x.Line1)%></div>
[Code].....
View 3 Replies
Oct 18, 2009
I need to display data from a complex sql query controlled by 2 combos. The sql main query part is working fine but I cannot get to link the combos to the query. On form load I load combo1 by means of a sub. Then with SelectedIndexChanged I load the combo2. Both combos load fine by do not intereact with eachothers meaning combo1 doen't filter out combo2's information.
CODE:
View 8 Replies
Dec 1, 2009
I'm trying to update an access .mdb file. The file contains one table with 115 fields. I have estabished a connection to the database. I'm able to select the datarow I want to update. I can see it when I debug the code. I change two fields in the datarow by using thier index.
[Code]...
View 7 Replies
Jul 26, 2010
I currently have a View in MVC where I pass a single set of data to the view. However, I've come across a problem where I am having to use a LINQ query within a For Each loop in the View to pull out additional information from a SQL View of data from another DB.
The error I'm getting is Late binding operations cannot be converted to an expression tree.
The particular snippet I'm encountering the error on is:
[Code]...
View 1 Replies
Sep 6, 2011
What I'm trying to do is more complex than this, but I'm trying to get over this hurdle.[code]...
View 2 Replies
May 23, 2012
The following LINQ query resp. call of the extension method Select in Visual Basic 2010 is working fine:
Dim qAvSalary = qJobData.Select(Function(e) e.AvSalary) But doing so I am not able to specify the name of property I want the query (e.g. AvSalary) using a string variable. This should be possible if I use a LINQ expression tree. Searching and trying a long time on how to translate the query to a corresponding expression tree was not successful. My final approach is:
[Code]...
View 1 Replies
Mar 7, 2011
I have built a database structure that represents a category tree to help classify some of the data we have stored. The implementation is that each record in the Category table has a nullable foreign key back into the Category table to represent the parent Category of this category (one-to-many), essentially allowing for subcategories within a broader parent level. There is a CategoryMembership table that links a record in the Item table to its respective Category (many-to-many). I have created the DBML for this database, and it has a member access structure that includes the following:
[Code]...
View 2 Replies
Oct 12, 2010
I am trying to write following expression on a datacolumn. But it results in error:Replicate('*', nLevel) + NameWhere: Replicate() is a user defined function (in a module). nLevel and Name are two other columns in same data table.
View 3 Replies
Feb 22, 2010
Im getting a build error with the following code...
Private Property GridViewSortDirection() As String
Get
Return If(TryCast(ViewState("SortDirection"), String), "ASC")
End Get
[CODE]...
It is happening on the following line...Return If(TryCast(ViewState("SortDirection"), String), "ASC")
Error returns...Error 11 C:inetpubwwwrootTPSupportmainUserControlsgrid.ascx.vb(192): error BC30201: Expression expected.
Its a convert from c#
private string GridViewSortDirection
{
get { return ViewState["SortDirection"] as string ?? "ASC"; }
set { ViewState["SortDirection"] = value; }
}
View 2 Replies
Jun 24, 2009
The build output path is ..inWhat does it mean ..?I mean what is the root folder?If there are multiple projects, should we set the individual path of each project consistently?
View 4 Replies
Mar 20, 2011
i need to build a regular expression to validate an code. The code has 10 charaters
- the First charaters can only one the following B,F,E,S,M,P,Z
- From Second to Seventh are alfanumeric (0-9 and A-Z)
- the Eighth is the letter U
- the ninth is a number (0-9)
-the tenth is alfanumeric (0-9 and A-Z)
View 7 Replies
Feb 9, 2009
I run my projects , automatically the output window pops up and tells me some extra info I ont need to see (normally...)==================------ Build started: Project: cm, Configuration: Debug Any CPU ------
View 2 Replies
Dec 29, 2010
Currently, I have this method to compare two numbers
Private Function ETForGreaterThan(ByVal query As IQueryable(Of T), ByVal propertyValue As Object, ByVal propertyInfo As PropertyInfo) As IQueryable(Of T)
Dim e As ParameterExpression = Expression.Parameter(GetType(T), "e")
[code]....
It works fine and is consumed in this way
query = ETForGreaterThan(query, Value, propertyInfo)
As you can see, I give it an IQueryable collection and it add a where clause to it, base on a property and a value. Y can construct Lessthan, LessOrEqualThan etc equivalents as System.Linq.Expressions.Expression has this operators predefined.How can I transform this code to do the same with strings? System.Linq.Expressions.Expression don't give me a predefined operator like "contains" or "startwith"?
View 2 Replies
Jun 8, 2012
I just want to parse simple expressions like IIF(FVAL(PFC) = TRUE, (IIF((ORGVAL(BAS, "2012/12/31") + ORGVAL(DA)) < 6500, (FVAL(BAS) + FVAL(DA)) * 12%, 780)), 0)`After parsing this I should be able to know what functions contains what parameters.
[Code]...
I'm stuck with .Net Framework 2.0, so no Linq or lambda expression goodies for me. Also I want to include the code in my custom library and not just reference it. Can anyone point me to some good library or code.
I just need to parse and not evaluate the expression and find what tokens are in use. After finding the tokens I need to change the expression string before parsing, like if the function ORGVAL is used then the parameter passed has has to be prefixed by an underscore. Like ORGVAL(BAS) will transform to ORGVAL(_BAS). Some functions can have tow parameters like ORGVAL(BAS, "2012/12/31") and this will transform to ORGVAL(_BAS, "2012/12/31")
NOTE: IF THERE ARE OTHER WAYS OF DOING IT PLEASE LET ME KNOW. I WOULD LOVE TO AVOID A PARSER AND LEXER.
View 3 Replies
Aug 24, 2009
I am a beginner so please be patient. I am trying to solve problems with existing code. We have a tree view where user may check off multiple files (tif,pdf, doc etc) for printing.When the print buttton is clicked each document should be printed. Each document must be printed in full before the next one starts. The docs are not printing in full or in order. I have attached the code for review.
Private Sub RecurseNodes(ByVal col As TreeNodeCollection)
For Each tn As TreeNode In col
If tn.Tag = "FILE" And tn.Checked Then
[code].....
View 3 Replies
Jun 12, 2009
Im currently working on a project to build an application for Windows Mobile 6.I have a SQL query string:
Dim connectionString2 As String = "Data source = " + path + "HC.sdf"
Dim cmdText2 = "SELECT * FROM BigC_Rangsit_0_"
I want to substitute the table name ie. BigC_Rangsit_0_ with a variable which contains the table name.say, during runtime the user selects a table from the dropdown list , that variable should be substituted with the selected table name dynamically in the SELECT statement.
Dim cmdText2 = "SELECT * FROM "selected table name VARiable""
well, I need the right syntax for this.
View 8 Replies
Jun 19, 2010
Is there any free tool available that can be used to build Active Directry query also can i execute active directry query through c# code because while connecting to active directory through object model and iterating through each property of the active directory specially when all the property is not requierd the performance cost is comming. What I want is to query Active Directory domain get some property value ans save it in the sharepoint list, I am using object model to do this but at the cost of the performance. I am thinking to execute the query through C# code same as any Active Diretory Query tool to pull the value and then save it into the list.
[Code]...
View 2 Replies
Dec 29, 2010
In my program I have a combo box that the user selects a date from and a list view that the user selects an employee ID from. How do I properly design my database query string to use both the date selected and the employee ID selected? The date is stored in a variable called YearMonth and the employee ID is stored in a variable called EmpID.
Here is what I am trying to do with my query:
Dim ExactQuery As String = _
"SELECT * " & _
"FROM[JobTypeExact_Query] WHERE (EMPID = ?) AND WHERE (YEARMONTH = YM)" 'Define Exact job type query
[code]....
View 6 Replies
Mar 10, 2009
I have the following C# LINQ query expression:
[code]...
how to convert this to VB.NET?
View 1 Replies
Jan 25, 2012
What I have right now is this:
Dim users = From users In tempTable _
Distinct Select users.Item("s_userid")
Dim usersCount As Integer = users.Count
But I pretty sure I shouldn't have to do that. I should be able to get the count in/from that first linq query.
View 2 Replies
Dec 9, 2011
I'm receiving the following error from the query below:
Syntax error (missing operator) in query expression 'LTC_FBS.DBS_NM = LTC_FBS_EMP.EMP_ID
INNER JOIN LTC_FBS_REV on LTC_FBS.FBS_REV = LTC_FBS_REV.REV_I'.
Dim sSQL As String = "SELECT FBS_ID, CLM_NUM, EMP_NM, REV_NM, DATE_SUBMIT FROM
[code].....
View 1 Replies
Jun 20, 2010
Anybody see anything wrong with this when I am inserting data into access
Dim cmd As New OleDbCommand("INSERT INTO SiteInformation VALUES(_TITLE)", connection)
cmd.Parameters.AddWithValue("_TITLE", "test")
I get syntax error in query expression '_TITLE'.
View 2 Replies