January 2008 Entries
I had some one ask me an interesting question about using linq with the datagridview
When I bind a datagridview to this query
Dim names() As String = {"hello11", "hello212", "hello123", "hello124", "hello2325", "hello336", "hello457"}
Dim query = From s In names _
Order By s _
Select s
Dim bs As New BindingSource
bs.DataSource = query
DataGridView1.DataSource = bs
Why do I get these results?
The answer the datagridview will show the properties of the class in the list bound to the datagridview. In this case we are bound to a list of string and the only bindable property is its Length. ...
Here is a simple linq query which places the numbers from 1 and 150 in a random order
Dim r As New Random(Now.Ticks Mod Int32.MaxValue)
Dim rndLst = From l In (From num In Enumerable.Range(1, 150) _
Select New With {.Num = num, .pos = r.Next(1, 150)}) _
Order By l.pos _
Select l.Num
For Each i In rndLst
Console.WriteLine(i)
Next
In the second post of this series we will make it so changes we make to the local data will be sent back to the server. Lets start by opening the project we created in the previous post.
So lets extend the SyncAgent Partial classes to make the sync 2 way. The class contains a partial method OnInitialized which you can add code to. In this method we will make the Products table Sync Direction Bidirectional.
Partial Public Class NorthwindSyncAgent
Private Sub OnInitialized()
Me.Products.SyncDirection = SyncDirection.Bidirectional
End Sub
End Class
Now what if there is a conflict? Let create a...
In this post we will create a local cache of the Northwind database. To start with lets create a new visual basic windows forms project in Visual Studio 2008. From the project menu select add a new item and select a new local database cache and name it northwind.
In the server connect select a connection to the northwind database.
Press the add button and select the product table. Press OK to close the dialog. Go ahead and create a table adapter for the product table. The drag the products table on to the form from the data source...
John Papa will be speaking about the Entity Framework at the Space Coast .Net User Group Feb 20,2008 meeting.
The ADO.NET Entity Framework, part of ADO.NET components of the .NET Framework, is an Object-Relational mapping technology from Microsoft. It is geared to solving the mismatch between the formats data is stored in a database and in which it is consumed in an object-oriented programming language or other front ends. ADO.NET Entity Framework will be released in the first half of 2008, separate from .NET Framework 3.5 and Visual Studio 2008.
John Papa, Senior Consultant for ASPSoft, Inc., a Microsoft MVP...