Question Required some examples using entity framework (linq)

kittu007

New member
Joined
May 4, 2011
Messages
2
Programming Experience
Beginner
Hi friends, I am trying to solve the Condition(if) in Vb.net using Linq(ado.net entity framework). Can i know some examples . That is how to get the data from Sql. For example is should get the Customer Starting with "A" should display in my datagridview.

for example
I have seen one example like this if condition. That condition it is calling from sql database

if searchcriteria.Contactname then
Contactlist = ContactList.Where(Function(a) a.v.ToUpper.StartsWith("s")
endif

So can i know how is it done. Can anyone explain me about this. As i was beginner to learn this things. Also Required some tasks to me to learn. Please Help me friends.Can u explain what is use of Function(a). and a.v.ToUpper
 
For a beginner, it's probably better to stick with query syntax rather than function syntax. The query syntax equivalent of that code is:
VB.NET:
ContactList = From a In ContactList _
              Where a.v.ToUpper.StartsWith("s") _
              Select a
That basically says create a list and assign it to ContactList where, for each item 'a' in ContactList whose 'v' field/property starts with "s", that item is added to the list. It's filtering the data based on the condition specified in the Where clause and only including items where that condition is True. The same goes for the function syntax version. It uses the Where function rather than a Where clause in a query but it also filters where the specified inline function returns True.
 
Back
Top