Skip to content

Instantly share code, notes, and snippets.

@TomDeFrank
Last active June 21, 2016 00:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TomDeFrank/50e3d364279b5a6c9103e385320721ca to your computer and use it in GitHub Desktop.
Save TomDeFrank/50e3d364279b5a6c9103e385320721ca to your computer and use it in GitHub Desktop.
Enitity Framework Examples

##Query Columns in a table

Using context As staffDBContext = New staffDBContext()
   Dim query = From m In context.tblStaffs
               Select New With
               {
                   .name = m.name,
                   .type = m.type,
                   .url = m.url
               }

   For Each result In query
       If result.type.ToLower = "advisor" Then
           Response.Write(result.url)
           Response.Write(result.name)
       End If
   Next         
End Using

##Update A Record

Using staffDBContext As New staffDBContext
    Dim query = From p In staffDBContext.tblStaffs
                Where p.name = "John Doe"
                Select p

    query.First.name = "Johnson Doeson"
    staffDBContext.SaveChanges()
End Using
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment