C# - Triple Dot Syntax For Linq To Xml
May 4, 2011I 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]...
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]...
tell me the equivalent syntax for the following code in VB.net?
Static Class TestList
{
static void Main()
{
[code].....
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?
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 ...
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 RepliesI'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.
I have the following XML file
<Test>
<Modules>
<Module Name= "Test1">
<QueueName Name="Test1Active1" Active="True"></QueueName>
<QueueName Name="Test1Active2" Active="True"></QueueName>
[Code]...
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)
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 RepliesI 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.
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 RepliesI 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]...
Public Shared Function DESEncrypt(ByVal Data As String, ByVal Key As String) As Byte() Dim IV() As Byte = {&H12, &H34, &H56, &H78, &H90, &HAB, &HCD, &HEF}
[Code]...
this is what I currently have for my DES encryption, but as I am fairly new to VB.Net I can figure out how to make it use Triple DES rather than DES
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]'.
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]...
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 RepliesI have data from an Informix database that has a column with data encrypted using the Informix function ENCRYPT_TDES. The data was imported into SQL SERVER 2008 and I no longer have access to a running instance of Informix. I need to write a C# or VB.NET function for decrypting that data. Anyone know how to write a C# function to decrypt it?
View 1 RepliesAs I'm sure many of you know, when you double click in a textbox, it selects part of the text, how could I make it where when you triple click on a textbox it selects all the text like a web browser address bar?
View 3 RepliesVS 2010 Single click for Triple click
View 22 RepliesI 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
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].....
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?
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 RepliesI want to select some rows from a sql express 2005 table. I am using this expression: "Starttime >= " & dtpStart.Value dtpStart is a DateTimePicker But I am getting this error: Syntax error: Missing operand after '14' operator.
View 18 Repliesgiven 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
if there is that much of a performance gain in running a LINQ stored procedure versus a LINQ query?
View 1 RepliesI have a listbox on my xaml form that I bound to a List(Of MyType) property. I populated this list like so:
Dim fields As List(Of CheckableFields) = New List(Of CheckableFields)
Using context As ITIPEntities = New ITIPEntities()
Try[code]....
Now I'm at the point where the user selects the fields they want included in a report and I need to iterate over the required fields. This is my linq query:
For Each checkedField In _requiredFields
If checkedField.IsChecked Then
If checkedField.FieldData IsNot Nothing AndAlso checkedField.FieldData.Trim IsNot String.Empty Then[code].....
Example-I have a person class
Public Class Person
Private _fname As String
Public Property Fname() As String
[Code]...
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."
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]....