Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Started work on porting the simple example to VB.Net

  • Loading branch information...
commit 9a103dde9778c18b3d799f129e0f34fa22ed4b4b 1 parent 2abd064
@samus authored
View
24 MongoDBDriver.sln
@@ -17,6 +17,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoDB.GridFS", "MongoDB.G
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoDB.GridFS.Tests", "MongoDB.GridFS.Tests\MongoDB.GridFS.Tests.csproj", "{0C293FE9-F670-4FEF-A60F-20F8C978B1CD}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{4345382B-FAA2-46E2-99CF-C90ACA2DD574}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Simple", "examples\Simple\Simple.csproj", "{131BDB5F-5C6F-4AC7-B03E-394B1B75E120}"
+EndProject
+Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SimpleVB", "examples\SimpleVB\SimpleVB.vbproj", "{1BAAE3D8-7720-4AA5-9335-E59824E7B667}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -27,6 +33,14 @@ Global
{0C293FE9-F670-4FEF-A60F-20F8C978B1CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0C293FE9-F670-4FEF-A60F-20F8C978B1CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0C293FE9-F670-4FEF-A60F-20F8C978B1CD}.Release|Any CPU.Build.0 = Release|Any CPU
+ {131BDB5F-5C6F-4AC7-B03E-394B1B75E120}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {131BDB5F-5C6F-4AC7-B03E-394B1B75E120}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {131BDB5F-5C6F-4AC7-B03E-394B1B75E120}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {131BDB5F-5C6F-4AC7-B03E-394B1B75E120}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1BAAE3D8-7720-4AA5-9335-E59824E7B667}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1BAAE3D8-7720-4AA5-9335-E59824E7B667}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1BAAE3D8-7720-4AA5-9335-E59824E7B667}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1BAAE3D8-7720-4AA5-9335-E59824E7B667}.Release|Any CPU.Build.0 = Release|Any CPU
{2E48891E-72F9-445D-9A5A-DBA787BFFE9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2E48891E-72F9-445D-9A5A-DBA787BFFE9E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E48891E-72F9-445D-9A5A-DBA787BFFE9E}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -54,6 +68,10 @@ Global
{C8BC95AB-25C6-4133-BC9F-8B6BB782CA02}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C8BC95AB-25C6-4133-BC9F-8B6BB782CA02}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {131BDB5F-5C6F-4AC7-B03E-394B1B75E120} = {4345382B-FAA2-46E2-99CF-C90ACA2DD574}
+ {1BAAE3D8-7720-4AA5-9335-E59824E7B667} = {4345382B-FAA2-46E2-99CF-C90ACA2DD574}
+ EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = MongoDBDriver\MongoDB.Driver.csproj
Policies = $0
@@ -76,6 +94,12 @@ Global
$4.inheritsSet = Mono
$4.inheritsScope = text/x-csharp
$4.scope = text/x-csharp
+ $0.TextStylePolicy = $5
+ $5.FileWidth = 120
+ $5.EolMarker = Windows
+ $5.inheritsSet = VisualStudio
+ $5.inheritsScope = text/plain
+ $5.scope = text/x-vb
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
View
89 examples/SimpleVB/Application.vb
@@ -0,0 +1,89 @@
+imports System
+imports System.Configuration
+
+imports MongoDB.Driver
+
+Namespace Simple
+
+ '''<summary>
+ '''Illustrates some simple operations on the database.
+ '''Creating a database connection.
+ '''Remove some documents.
+ '''Insert some documents
+ '''Find one document
+ '''Find several documents and iterate through them.
+ '''</summary>
+
+ Public Class Application
+ Private mongo as Mongo
+ Private simple as Database
+ Private categories as IMongoCollection
+
+ Public Shared Sub Main()
+ Dim app As New Application()
+ app.Setup()
+ //main.Run()
+ End Sub
+
+ ''' <summary>
+ ''' Setup the collection and insert some data into it.
+ ''' </summary>
+ Public Sub Setup()
+ dim connstr as string = ConfigurationManager.AppSettings("simple")
+ if String.IsNullOrEmpty(connstr) then throw new ArgumentNullException("Connection string not found.")
+ mongo = new Mongo(connstr)
+ mongo.Connect()
+ simple = mongo("simple")
+ categories = simple("categories")
+ //Clean()
+
+ Dim names() As String = {"Bluez", "Jazz", "Classical", "Rock", "Oldies", "Heavy Metal"}
+
+ For Each name As string In names
+ categories.Insert(new Document().Append("name", name))
+ Next
+ End Sub
+
+ Public Sub Clean()
+ categories.Delete(new Document().Append("name", "Jazz")) 'remove documents with the name Jazz.
+ categories.Delete(new Document()) 'remove everything from the categories collection.
+ End Sub
+ Public Sub Run()
+ Dim category As Document = categories.FindOne(new Document.Append("name", "Bluez"))
+
+ Console.WriteLine ("The id findOne" + category("_id"))
+
+ Dim selector As Document = New Document().Append("_id", category("_id"))
+
+ category("name") = "Bluess"
+ 'The following will do the same thing.
+ categories.Update(category)
+
+ Console.WriteLine("Category after one update " + categories.FindOne(selector).ToString())
+
+ category("name") = "Blues"
+ categories.Update(category, selector)
+
+ Console.WriteLine("Category after two updates " + categories.FindOne(selector).ToString())
+
+ 'Find it by _id that has been converted to a string now.
+ Dim id As String = CType(category("_id"),Oid).ToString()
+
+ Console.WriteLine("Found by string id converted back to Oid")
+ Console.WriteLine(categories.FindOne(new Document().Append("_id", new Oid(id.Replace("""", "")))).ToString())
+
+ 'Find(new Document()) is equivalent to FindAll()
+ 'Specifying the cursor in a using block will close it on the server if we decide not
+ 'to iterate through the whole thing.
+REM using(ICursor all = categories.Find(new Document())){
+REM foreach(Document doc in all.Documents){
+REM Console.WriteLine(doc.ToString());
+REM }
+REM }
+
+ mongo.Disconnect()
+ End Sub
+
+ End Class
+
+End Namespace
View
25 examples/SimpleVB/AssemblyInfo.vb
@@ -0,0 +1,25 @@
+Imports System.Reflection
+Imports System.Runtime.CompilerServices
+
+' Information about this assembly is defined by the following attributes.
+' Change them to the values specific to your project.
+
+<assembly: AssemblyTitle("SimpleVB")>
+<assembly: AssemblyDescription("")>
+<assembly: AssemblyConfiguration("")>
+<assembly: AssemblyCompany("")>
+<assembly: AssemblyProduct("")>
+<assembly: AssemblyCopyright("")>
+<assembly: AssemblyTrademark("")>
+<assembly: AssemblyCulture("")>
+
+' The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+' If the build and revision are set to '*' they will be updated automatically.
+
+<assembly: AssemblyVersion("1.0.0.0")>
+
+' The following attributes are used to specify the signing key for the assembly,
+' if desired. See the Mono documentation for more information about signing.
+
+<assembly: AssemblyDelaySign(false)>
+<assembly: AssemblyKeyFile("")>
View
1  examples/SimpleVB/SimpleVB.vbproj
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?>
Please sign in to comment.
Something went wrong with that request. Please try again.