Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Are these queries doing the same thing

Are these queries doing the same thing

Scheduled Pinned Locked Moved Visual Basic
databasesql-serversysadminquestioncareer
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    desanti
    wrote on last edited by
    #1

    Hello ! I'm using Entity Framework 6 with sql server 2008r2 database. I want to get from database only those records that have vl1>5.( i need to get from database only those objects that have vl1>5 and not to read all the objects and after to apply the condition ) I have 2 queries :

    Dim query1 as IeQueryable(of myobj)= (From t in context.myobjs Where vl1<5).Tolist

    Dim query2= (From t in context.myobjs.Asqueryable Where vl1<5).Tolist

    Are these queries doing the same job that i want ?

    L 2 Replies Last reply
    0
    • D desanti

      Hello ! I'm using Entity Framework 6 with sql server 2008r2 database. I want to get from database only those records that have vl1>5.( i need to get from database only those objects that have vl1>5 and not to read all the objects and after to apply the condition ) I have 2 queries :

      Dim query1 as IeQueryable(of myobj)= (From t in context.myobjs Where vl1<5).Tolist

      Dim query2= (From t in context.myobjs.Asqueryable Where vl1<5).Tolist

      Are these queries doing the same job that i want ?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      What happens when you try them?

      1 Reply Last reply
      0
      • D desanti

        Hello ! I'm using Entity Framework 6 with sql server 2008r2 database. I want to get from database only those records that have vl1>5.( i need to get from database only those objects that have vl1>5 and not to read all the objects and after to apply the condition ) I have 2 queries :

        Dim query1 as IeQueryable(of myobj)= (From t in context.myobjs Where vl1<5).Tolist

        Dim query2= (From t in context.myobjs.Asqueryable Where vl1<5).Tolist

        Are these queries doing the same job that i want ?

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        desanti wrote:

        and not to read all the objects and after to apply the condition )

        Then use an SQL query and execute your statement on the server, instead of using an ORM. The only difference between the first and second version is the "Asqueryable" part in the second statement; that statement has nothing to do with "where" the query executes. So, to answer, yes, they're doing the same job. Not sure if it's what you want though.

        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups