Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions LINQ to Objects demo1/LINQ to Objects demo1.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "VBLinqToObject", "VBLinqToObject\VBLinqToObject.vbproj", "{1F187E80-A962-4EC9-9886-C59EC100E625}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{66E60E0C-AE02-42BA-9281-2D9DE26F61F3}"
ProjectSection(SolutionItems) = preProject
C:\USERS\VBJAY\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\14.0\EXTENSIONS\T4HCFCDO.0KS\description.html = C:\USERS\VBJAY\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\14.0\EXTENSIONS\T4HCFCDO.0KS\description.html
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1F187E80-A962-4EC9-9886-C59EC100E625}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1F187E80-A962-4EC9-9886-C59EC100E625}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1F187E80-A962-4EC9-9886-C59EC100E625}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1F187E80-A962-4EC9-9886-C59EC100E625}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
2,075 changes: 2,075 additions & 0 deletions LINQ to Objects demo1/VBLinqToObject/Documentation/ReadMe.htm

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<a:clrMap xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" bg1="lt1" tx1="dk1" bg2="lt2" tx2="dk2" accent1="accent1" accent2="accent2" accent3="accent3" accent4="accent4" accent5="accent5" accent6="accent6" hlink="hlink" folHlink="folHlink"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<xml xmlns:o="urn:schemas-microsoft-com:office:office">
<o:MainFile HRef="../ReadMe.htm"/>
<o:File HRef="themedata.thmx"/>
<o:File HRef="colorschememapping.xml"/>
<o:File HRef="image001.png"/>
<o:File HRef="image002.jpg"/>
<o:File HRef="filelist.xml"/>
</xml>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
106 changes: 106 additions & 0 deletions LINQ to Objects demo1/VBLinqToObject/MainModule.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
'****************************** Module Header ******************************\
' Module Name: Program.cs
' Project: VBLinqToObject
' Copyright (c) Microsoft Corporation.
'
' This example illustrates how to write Linq to Object queries using Visual
' VB.NET. First, it builds a class named Person. Person inculdes the ID,
' Name and Age properties. Then the example creates a list of Person which
' will be used as the datasource. In the example, you will see the basic
' Linq operations like select, update, orderby, max, average, etc.
'
' This source is subject to the Microsoft Public License.
' See http://www.microsoft.com/en-us/openness/resources/licenses.aspx#MPL.
' All other rights reserved.
'
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
' WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ***************************************************************************/

Module MainModule

Sub Main()

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Build the Person list that serves as the data source.
'
Dim persons As New List(Of Person)

persons.Add(New Person(1, "Alexander David", 20))
persons.Add(New Person(2, "Aziz Hassouneh", 18))
persons.Add(New Person(3, "Guido Pica", 20))
persons.Add(New Person(4, "Chris Preston", 19))
persons.Add(New Person(5, "Jorgen Rahgek", 20))
persons.Add(New Person(6, "Todd Rowe", 18))
persons.Add(New Person(7, "SPeter addow", 22))
persons.Add(New Person(8, "Markus Breyer", 19))
persons.Add(New Person(9, "Scott Brown", 20))

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Query a person in the data source.
'
Dim Todd = (From p In persons
Where p.Name = "Todd Rowe"
Select p).First()

Console.WriteLine("Todd Rowe's age is {0}", Todd.Age)

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Perform the Update operation on the person's age.
'
Todd.Age = 21

Console.WriteLine("Todd Rowe's age is updated to {0}", (From p In persons
Where p.Name = "Todd Rowe"
Select p).First().Age)

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Sort the data in the data source.
' Order the persons by age
Dim query1 = From p In persons
Order By p.Age
Select p

Console.WriteLine("ID" & vbTab & "Name" & vbTab & vbTab & "Age")

For Each p In query1.ToList()
Console.WriteLine("{0}" & vbTab & "{1}" & vbTab & vbTab & "{2}",
p.PersonID, p.Name, p.Age)
Next

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Print the average, max, min age of the persons.
'
Dim avgAge As Double = (From p In persons
Select p.Age).Average()
Console.WriteLine("The average age of the persons is {0:f2}", avgAge)

Dim maxAge As Double = (From p In persons
Select p.Age).Max()
Console.WriteLine("The maximum age of the persons is {0}", maxAge)

Dim minAge As Double = (From p In persons
Select p.Age).Min()
Console.WriteLine("The minimum age of the persons is {0}", minAge)

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Count the persons who age is larger than 20.
'
Dim query2 = From p In persons
Where p.Age > 20
Select p

Dim count As Integer = query2.Count()

Console.WriteLine("{0} persons are older than 20:", count)

For i = 0 To count - 1
Console.WriteLine(query2.ElementAt(i).Name)
Next
Console.WriteLine("Press any key to quit...")
Console.ReadKey()

End Sub

End Module

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions LINQ to Objects demo1/VBLinqToObject/My Project/Application.myapp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<MySubMain>false</MySubMain>
<SingleInstance>false</SingleInstance>
<ShutdownMode>0</ShutdownMode>
<EnableVisualStyles>true</EnableVisualStyles>
<AuthenticationMode>0</AuthenticationMode>
<ApplicationType>2</ApplicationType>
<SaveMySettingsOnExit>true</SaveMySettingsOnExit>
</MyApplicationData>
35 changes: 35 additions & 0 deletions LINQ to Objects demo1/VBLinqToObject/My Project/AssemblyInfo.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Imports System
Imports System.Reflection
Imports System.Runtime.InteropServices

' General Information about an assembly is controlled through the following
' set of attributes. Change these attribute values to modify the information
' associated with an assembly.

' Review the values of the assembly attributes

<Assembly: AssemblyTitle("VBLinqToObject")>
<Assembly: AssemblyDescription("")>
<Assembly: AssemblyCompany("Microsoft Corporation")>
<Assembly: AssemblyProduct("VBLinqToObject")>
<Assembly: AssemblyCopyright("Copyright © Microsoft 2010")>
<Assembly: AssemblyTrademark("")>

<Assembly: ComVisible(False)>

'The following GUID is for the ID of the typelib if this project is exposed to COM
<Assembly: Guid("6a63329b-d8e9-419a-92f5-58445a090f7e")>

' Version information for an assembly consists of the following four values:
'
' Major Version
' Minor Version
' Build Number
' Revision
'
' You can specify all the values or you can default the Build and Revision Numbers
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>

<Assembly: AssemblyVersion("1.0.0.0")>
<Assembly: AssemblyFileVersion("1.0.0.0")>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

117 changes: 117 additions & 0 deletions LINQ to Objects demo1/VBLinqToObject/My Project/Resources.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema

Version 2.0

The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.

Example:

... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>

There are any number of "resheader" rows that contain simple
name/value pairs.

Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.

The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:

Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.

mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
Loading