C# - What Operators Should Have LINQ Query Expression Support
Oct 2, 2009
Of the 51 Standard Query Operators (of which only 42 are actually query operators), only 24 are directly supported by Visual Basic 9 and just 11 by C# 3: Query Expression Syntax for Standard Query Operators.In many cases, query syntax is arguably more readable than the equivalent method syntax, especially when transparent identifiers are involved. However, that readability breaks down if you have to combine queries and method calls.So the question: What query operators, current or hypothetical, would you like to have your language of choice support in query expression syntax?
View 2 Replies
ADVERTISEMENT
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
Feb 25, 2011
I have a query that I cannot seem to replicate in expression method chain syntax. I have two tables "User" and "UserPayment". User and UserPayment have a one to many relation i.e. One User can have many UserPayments.
View 1 Replies
Feb 5, 2010
I must convert string data from a CNC that is arithmetic expression to a number that I can use in a VB application that I wrote. The following is what I get out of the cnc. [18722*65536+19377]/67108864. I need to evaluate this expression in my VB ap. The format of the string is not always the same as what I have illustrated.
View 2 Replies
Feb 17, 2012
I recently installed visual studio 2010 and am using visual basic.The problem I am having is that some operators do not show up within the editor. For example the code line below
test = 3 + 5 - 6 / 7 * 4
only displays
test 3 5 - 6 / 7 * 4
the = + operators are not visible although they are there since the program will work as intended....and if I open up the .vb file in notepad everything is there. It just won't display within Visual Studio.
View 5 Replies
Sep 22, 2009
I know that LINQ queries are deferred and only executed when the query is enumerated, but I'm having trouble figuring out exactly when that happens.Certainly in a For Each loop, the query would be enumerated.What's the rule of thumb to follow? I don't want to accidentally enumerate over my query twice if it's a huge result.
For example, does System.Linq.Enumerable.First enumerate over the whole query? I ask for performance reasons. I want to pass a LINQ result set to an ASP.NET MVC view, and I also want to pass the First element separately. Enumerating over the results twice would be painful.It would be great to turn on some kind of flag that alerts me each time a LINQ query is enumerated. That way I could catch scenarios when I accidentally enumerate twice.
View 3 Replies
May 31, 2011
When I execute the code below I receive the error message: LINQ to Entities does not recognize the method 'System.Object CompareObjectEqual(System.Object, System.Object, Boolean)' method, and this method cannot be translated into a store expression.It seems to be occurring on the line For Each row2 in PCstudent.
[Code]...
View 1 Replies
Jul 14, 2011
given this function:
Public Function Search(ByVal StartIndex As Integer, _
ByVal MaxResults As Integer, _
ByVal AccountNumber As String, _
ByVal LastName As String, _
[Code]....
instead of what I expected:
Select count(*) from remitline where lastname = "smith"
What am I doing wrong building up the where clause? I'm using Castle ActiveRecord 2.1
View 1 Replies
Aug 6, 2009
if there is that much of a performance gain in running a LINQ stored procedure versus a LINQ query?
View 1 Replies
Mar 25, 2010
I have an multi-database ODBC connection through a DSN. There is a primary database and two auxiliary catalogs. The Add Tables dialog in Microsoft Query only shows the tables in the primary database. If I pick one and continue on, the lists of columns in other parts of MS Query show all the columns in both the primary and auxiliary databases. If I pick a column, MS Query will look for that column in the primary database (great if it happens to be there, not so great if it doesn't). If I don't use any of the drop-down lists and just write a query in the freeform SQL editor, fully qualifying everything with the catalog names, the query runs fine.It looks as though MS Query is assuming only one database and one (default) catalog, and doesn't realize that it actually connected to several databases with separate catalogs.I get the same results with Office 2003 and Office 2007.Are multiple databases / multiple catalogs through a single DSN supported in Excel / Microsoft Query?
View 1 Replies
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 23, 2010
I just upgraded from Visual Studio 2005 to Visual Studio 2010 yesterday. I tried opening my site; it started the conversion wizard and seemed to work OK. However, I get the error "Visual Basic 9.0 does not support this kind of lambda expression." Here is my code:[code]....
The error is on the "Function()" line. I thought multi-line lambda functions were one of the new VS2010 features. Why am I getting a VB9.0 error in VS2010?
View 1 Replies
Mar 31, 2011
Forgive my ignorance on this.I have this LINQ Query:Dim ngBikersDataContext As New CarBikeWalkDataContext
bikersList = (From c In ngBikersDataContext.Reg_Bikers _
Order By c.L_Name _
Select New Bikers() With { _
.BikerID = c.BikerID, _
.F_Name = c.F_Name, _
[Code]...
with the error "Overload resolution failed because no accesible 'Select' accepts this number of arguments."
Over the "NEW" I get an error " ')'expected."
View 1 Replies
Nov 17, 2009
convert this C# code to VB, tried couple of converters and they dont work properly.
[Code]...
View 6 Replies
Mar 30, 2010
[QueryInterceptor("Somethings")]
public Expression<Func<Something, bool>> OnSomethings()
{
// Code here
}
I had a view guesses, looked on msdn, but there are no examples matching the way that that is used.
View 1 Replies
Nov 18, 2010
I'm having a little trouble converting some LINQ to VB.[code]Online code translators are not helping, and my unfamiliarly with VB LINQ is not very good.
View 2 Replies
Aug 6, 2011
THE CODE IS :
var query1 = ((from c in dt.AsEnumerable()
orderby c.Field<int>("1") descending
select c));
var query2 = (from c in query1.Take(10)
select c);
[Code]...
View 1 Replies
Jun 9, 2010
I have the same problem as stated in this question, but the accepted solution there was a "works on my machine" answer.
[Code]...
And I receive the error: BC30201: Expression expected.
Does anyone have a more detailed idea of what could cause this?
View 1 Replies
Dec 15, 2011
How to Join the objects in a LINQ select in this sample (C# variants accepted as well):
Class Room
Public Area As Integer
End Class
Class RoomPair
[code]....
View 4 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
May 21, 2010
I need to test a logical expression held in a string to see if it evaluate to TRUE or FALSE.(the strig is built dynamically)For example the resulting string may contain "'dog'<'cat' OR (1>4 AND 4<6)". There are no variables in the string, it will logically evaluate. It will only contain simple operators = > < >< >= <= and AND , OR and Open and Close Brackets, string constants and numbers. (converted to correct syntax && || etc.)
I currently acheive this by creating a jscipt function and compiling it into a .dll. I then reference the .dll in my VB.NET project.
class ExpressionEvaluator
{
function Evaluate(Expression : String)
{
return eval(Expression);
}
}
Is there a simpler method using built in .NET functions or Lamdba expressions.
View 2 Replies
Feb 3, 2011
Where can I find complex LINQ examples made using VB.NET Lambda Expression syntax?During my searches I always found 101 LINQ Samples but they use the other notation and for me is not always clear how to transform that code into a lambda expression.
View 1 Replies
May 4, 2012
[code]The LINQ query going into "result" is incomplete because I'm stumped at what is happening there. I expect FirstOrDefault to refer to refer to a single Child object at that point in the expression, but it refers to a collection of child objects. Why? What is the best way to get a list of parents that have no associated child or have a child fitting a particular condition? (My actual code will have one child max, so this sample code is not representative.)I just don't understand what the collection of FirstOrDefault could be referring to. It should really be just 1 value or nothing at all times.
View 1 Replies
Nov 28, 2010
translation of the following C# Linq Expression (in VB.NET 2008):
syncContext.Send((obj) => eventToBeFired(this, new EventArgs()), null);
Is used in this subroutine:
private void FireEvent(EventHandler eventToBeFired)
{
if (eventToBeFired != null)
{
[code]....
View 3 Replies
Jan 27, 2011
We are doing a query against an in-memory collection of LINQ data objects. The wrinkle is that we are ordering by a column in a related table whose records have not necessarily been loaded yet (deferred loading:)
Dim oPkgProducts = _
From b In oBillPkg.BillProducts _
Where b.Successful.GetValueOrDefault(Common.X_INDETERMINATE) = _
[code]....
View 1 Replies
Aug 31, 2011
How do I add ROW_NUMBER to a LINQ query or Entity? How can I convert this solution to VB.NET?
[Code]...
I'm having trouble porting that last line. I have been unable to locate a VB.NET example. I'm actually not looking for any paging functionality like the example provides, just good old-fashioned Row_Number(Order By X) row index.
View 1 Replies
Apr 5, 2011
I know there are similar questions on stackoverflow - and I looked through them and think my issue is somewhat similar, but haven't been able to find a solution by looking at any of these other questions/answers.I'm getting the error when attempting to execute the following code:
Private Sub btnReserve_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnReserve.Click
' Check that the room is still available.
Dim dbCheckOccupants As New pbu_housingEntities
Dim hall As String = CStr(Session("hall"))
[code]....
It is catching an error on this line:
Dim myID As String = GetID.First.id.ToString
As far as I can tell I'm not using multiple contexts?
View 2 Replies
Feb 3, 2011
I am trying to convert the following code for the variance calculation
public static double Variance(this IEnumerable<double> source){
double avg = source.Average();
double d = source.Aggregate(0.0,
(total, next) => total += Math.Pow(next - avg, 2));
return d / (source.Count() - 1);
}
Described on CodeProject into corresponded VB.NET lambda expression syntax, but I am stuck in the conversion of Aggregate function. How can I implement that code in VB.NET?
View 1 Replies
Nov 18, 2010
I am finding this weird issue. When I do this > activities.Where(Function(a) (Not a.IsDeleted And a.ParentId = 100) It returns an in-memory query & when I try opening it up, it throws a object not set exception. This only happens when there were no items which satisfied the condition. Shouldn't it be returning an empty set? When there are items satisfying the condition, then it returns a list & works all good.
View 1 Replies