Linq Syntax In Program?
May 28, 2009
What I really want is to select these two tables in to an anon type like in Scott Gu's blog: here However, I would settle for this created type "ActiveLots" I am joining two tables together and want to be able to reference columns from each in my result set. [code]...
View 1 Replies
ADVERTISEMENT
Jul 14, 2009
tell me the equivalent syntax for the following code in VB.net?
Static Class TestList
{
static void Main()
{
[code].....
View 3 Replies
May 4, 2011
I ran into this answer which had a triple dot syntax in VB.NET that I have never seen before. The query looks like this
[Code]...
View 3 Replies
Jun 29, 2011
After I have programmed several projects in VB.Net I to my surprise discovered that there are some more than subtle differences between C# and VB.NET LINQ usage.For example, if we want to group elements by multiple properties (columns) we need to create a new anonymous type explicitly:
var procs = from c in Process.GetProcesses()
group c by new {c.BasePriority, c.Id} into d
select d;
whereas in VB.NET more straightforward syntax will already do:
Dim b = From c In Process.GetProcesses()
Group c By c.BasePriority, c.Id Into Group
Select Group
So, one does not need to create a type with "new" here. What are the other differences? good comparison between the LINQ syntax in C# and VB.NET?
View 2 Replies
May 5, 2009
I'd like to do a subtraction of sets based on criteria. A pseudo-query would look like:
select table1.columnn1
,table1.column2
from table1, table2
[Code]....
I can make it to about here:
dim list = From tbl1 In table1 Where tt.column1 ...
View 1 Replies
May 13, 2009
I'm a bit of a LINQ newbie and I was having some trouble with the following. I'm trying to perform a query using LINQ on an XML file and store the results in a list of DataClass objects that match the XML.I've got an XML file that is defined like this:
<NewDataSet>
<NewDataTable>
<Field>Accepted ASNs</Field>
<Val>59</Val>[code]....
I have created a Data class to support this XML format. What I would like to do is create a LINQ Query to grab these 3 records and store them into a List of my DataClass. In order to support multiple Order elements, I have my class defined with a generic list of "Order" structs... It looks like this:
Public Class ASNData
Private _field As String
Private _value As String[code].....
how to grab the 3 order elements and store them into my list of Order structs.
View 4 Replies
Dec 10, 2010
I have the following XML file
<Test>
<Modules>
<Module Name= "Test1">
<QueueName Name="Test1Active1" Active="True"></QueueName>
<QueueName Name="Test1Active2" Active="True"></QueueName>
[Code]...
View 1 Replies
Aug 6, 2010
I'm trying to grasp the linq to xml 'inline query syntax' features of VB.Net First I tried with this simple xml file:
<?xml version="1.0" encoding="utf-8" ?>
<Root>
<Child Name="somename">
[code]....
This xml, when loaded in an XDocument, can be loaded and queried as follows:
Dim xdoc = XDocument.Load("sample.xml")
Console.WriteLine(xml.Root.<Child>.@Name)
Then I change the <Root> element in the sample xml file to:
<Root xmlns="http://SomeNamespace">
Now I can't seem to use the convenient 'Axis Properties' syntax anymore... I can only get it to work with the explicit XElement syntax:
Dim ns As XNamespace = "http://SomeNamespace"
' works, but I would like to use the same syntax as above...
Console.WriteLine(xdoc.Descendants(ns + "Child").First().Attribute("Name").Value)
View 1 Replies
Jan 24, 2012
I am building an xml file with the help of Linq queries and I'm not sure why the code below doesn't work.[code]
View 1 Replies
Dec 3, 2009
I am trying to AVERAGE 6 different fields on a DataTable, but without grouping. Just the AVERAGE. I have found a couple of examples in C#, but can't find any examples for how to do this in VB.Here is what I have so far:
Dim query = From dtRow In dtIn.AsEnumerable _
Where dtRow.Field(Of String)("FOLLOWUP") = "Alert" _
Select New With { _
.Brand_Functional_Avg = XXX.Average(Function(f) f("Brand_Functional")), _
.Brand_Personal_Avg = XXX.Average(Function(f) f("Brand_Personal")) _
}
What should I use for XXX? I tried all of the options that I could think of and nothing is compiling.
Trust me, if I could write this in C#, I would, but the project requires VB.
View 1 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
May 25, 2011
I have a LINQ to sql statement that joins 2 tables. I would like to add a order by clause on one of the columns. However the order by clause does not seem to take effect at all. right syntax in VB.net to achieve order by in the following:
Dim query = From dtIt In dbsomecontext.mytable
Join dtIl In dbsomecontext.anothertable On dtIt.ItemID Equals dtIl.ItemID
Where dtIl.IsAvailable = True
Order By dtIt.manufacturer
[Code]...
View 2 Replies
Sep 13, 2011
What is the proper syntax for this:
Dim qry As <??> = From f In dirInfo.GetFiles("*.QBW") Select File = f.FullName, Include = True
Dim dt As DataTable = qry.CopyToDataTable()
I tried as "IEnumerable(Of DataRow)" but that didn't work. At runtime it said:
Unable to cast object of type
'WhereSelectArrayIterator2[System.IO.FileInfo,VB$AnonymousType_02[System.String,System.Boolean]]'
to type
'System.Collections.Generic.IEnumerable`1[System.Data.DataRow]'.
View 5 Replies
Jul 14, 2009
I've been trying to write this snippet of code in VB, can anyone see what is wrong with it? I am recieving an error on line 5.
Dim a1 = From rows In db.tPDMLinkUsages _
Where (rows.ACCESSDATE >= DateTime.Today.AddDays(-90)) _
Select New With _
{ _
[CODE]...
View 5 Replies
Jun 29, 2010
I'm trying to translate some C# LINQ code into VB.NET and am stuck on how to declare an anonymous type in VB.NET.[code]How do you translate C#'s new { ... } syntax into VB.NET?
View 2 Replies
Nov 18, 2010
I was trying to convert 1 syntax to VB.net over the online converter but it does not work.[code]...
View 4 Replies
Nov 18, 2009
I am having a problem with the syntax of this calculation for a bowling program that I am writing for school,
If radMale.Checked = True Then
(200 - decAverage) * .75
lblAverage.Text = FormatNumber(decAverage)
View 1 Replies
Mar 2, 2010
I need to interpolate a string containing a file name into this statement...
fileReader = My.Computer.FileSystem.ReadAllText("C:myfile.txt")
View 8 Replies
Jun 6, 2011
I have a datagridview on my form which displays records from Mysql table on form load.i want to delete the selected row in datagrid from table on 'row header mouse click' event.
The 2 different codes that i tried --- deletes the record from the datagrid for a moment but does not delete from mysql table & re-appears when closed & debugged again.[code]...
View 6 Replies
Apr 21, 2012
I have this sql statement to update a column in access db from vb but when I run the program it shows that there is a syntax error in the statement. [code]...
View 2 Replies
Jul 10, 2010
I have made a smtp client in c# and I use this code to split a string that contains multiple recipients.
foreach (var n in txtSendTo.Text.Split(';'))
{
mail.To.Add(n);
[code].....
View 3 Replies
Oct 12, 2011
I am having an issue trying to figure this out. I am writing a script editor that uses tabs (a tab control) and I want to implement syntax highlighting. My issue is that every sample I can find on syntax highlighting uses
Private Sub RichTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged
View 1 Replies
Aug 9, 2010
How do i great dynamic linq query in VB.net?
View 3 Replies
Apr 12, 2012
I am working on an application in which i need to use reporting. i have used LINQ to entities and MS SQL server as database in my whole application. Now when i started working reports i noticed that crystal reports or no more included in visual studio. i downloaded it separately and installed it. i have also designed my report successfully but the problem is that how would i use LINQ with it?? I translated my linq query into datatables and it worked but the problem i am stuck at is, my report is based on two tables, after translation i am able to see records of first table but not the second one.
View 1 Replies
Oct 25, 2010
I am new to LINQ, but have been able to query SQL using LINQ to SQL and then I can data bind the results to a GRID or DROPDOWN LIST with no problem. What I would like to do is load a column into an array. I have seen examples for something like this in C#[code]...
View 12 Replies
Mar 18, 2011
I have done a lot of searching to what appears to be a simple LINQ problem but I can't figure out how to do grab an object out of a collection that has a specified minimum (or max value) without resorting to a sort like this[code]...
View 3 Replies
Dec 16, 2009
Can any one translate the following syntax to vb.net.
m_TextBox.Loaded += TextBoxLoaded
m_TextBox.Loaded -= TextBoxLoaded;
private void TextBoxLoaded(object sender, RoutedEventArgs e)[code].....
View 4 Replies
Oct 14, 2011
I've build a large program with many references. F.e.:
System.Data.DataSetExtensions
System.Linq.Dynamic
I've to write a Dynamic Linq Expression: [URL]
In my case: Dim query As IEnumerable = ds.Sales.Where(strWhere)
But with System.Data.DataSetExtensions Where is misinterpreted. The compiler expects (Datarow, Integer, Boolean). If I delete System.Data.DataSetExtensions everything is ok with this expression, but I get many other errors, so I need this reference. What can I do that the Where is interpreted correctly?
View 1 Replies
Sep 5, 2011
i have this code:Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
[Code]...
Error 1: Option Strict On disallows late binding.Im using visual basic 2010 express on a gateway laptop thats running Windows 7 OS How do i resolve this error?
View 2 Replies
Apr 9, 2009
I have a listbox and it it I am showing numbers.It should look like this (line by line) 1,2,3,4,5,6,7,8,9,10,11.....but is is showing it like this 1,10,11,...2,20,21...3,30...ow can I make it that it will show it in number order 1,2,3,4,5......
View 5 Replies