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
  1. Home
  2. General Programming
  3. C#
  4. New problem with linq just started ... anyone seen this?

New problem with linq just started ... anyone seen this?

Scheduled Pinned Locked Moved C#
helpcsharpdatabaselinqbusiness
6 Posts 3 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.
  • M Offline
    M Offline
    Michael J Eber
    wrote on last edited by
    #1

    I have one application that we lost the source code to that I'm rewriting and another app I'm writing to help a business partner that I started yesterday. I created a class project, removed the Class1 library, then added the Linq to Sql class type. So far so good. I added my tables and queries and rebuilt the application to start coding. But when I start my normal process using (MasterContext context = new MasterContext()){} I keep getting the error that the context cannot be converted to IDisposable. WTF???!!!! I've done everything I can think of but I keep getting this error. Also if I get rid of the using a write a select, the variable used in the from statement refuses to expand. Now I know that is usually a sign that I've screwed something up, but I cannot see what it could possibly be. Any input would be greatly appreciated. Michael

    R K 2 Replies Last reply
    0
    • M Michael J Eber

      I have one application that we lost the source code to that I'm rewriting and another app I'm writing to help a business partner that I started yesterday. I created a class project, removed the Class1 library, then added the Linq to Sql class type. So far so good. I added my tables and queries and rebuilt the application to start coding. But when I start my normal process using (MasterContext context = new MasterContext()){} I keep getting the error that the context cannot be converted to IDisposable. WTF???!!!! I've done everything I can think of but I keep getting this error. Also if I get rid of the using a write a select, the variable used in the from statement refuses to expand. Now I know that is usually a sign that I've screwed something up, but I cannot see what it could possibly be. Any input would be greatly appreciated. Michael

      R Offline
      R Offline
      RugbyLeague
      wrote on last edited by
      #2

      Does MasterContext implement IDisposable? If not you can't have it in a using

      M 1 Reply Last reply
      0
      • M Michael J Eber

        I have one application that we lost the source code to that I'm rewriting and another app I'm writing to help a business partner that I started yesterday. I created a class project, removed the Class1 library, then added the Linq to Sql class type. So far so good. I added my tables and queries and rebuilt the application to start coding. But when I start my normal process using (MasterContext context = new MasterContext()){} I keep getting the error that the context cannot be converted to IDisposable. WTF???!!!! I've done everything I can think of but I keep getting this error. Also if I get rid of the using a write a select, the variable used in the from statement refuses to expand. Now I know that is usually a sign that I've screwed something up, but I cannot see what it could possibly be. Any input would be greatly appreciated. Michael

        K Offline
        K Offline
        Keith Barrow
        wrote on last edited by
        #3

        System.Data.Linq.DataContext implements IDisposable, so MasterContext will too if it subclasses System.Data.Linq.DataContext. Check your inheritance hierarchy (not forgetting partial class files). It is also possible that something has gone wrong in auto-generation, if all else fails, I suggest is a restart (which fixes a surprising number of the odder problems).

        Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter. Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.

        M 1 Reply Last reply
        0
        • K Keith Barrow

          System.Data.Linq.DataContext implements IDisposable, so MasterContext will too if it subclasses System.Data.Linq.DataContext. Check your inheritance hierarchy (not forgetting partial class files). It is also possible that something has gone wrong in auto-generation, if all else fails, I suggest is a restart (which fixes a surprising number of the odder problems).

          Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter. Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.

          M Offline
          M Offline
          Michael J Eber
          wrote on last edited by
          #4

          That was the 'trick'. Everything that was 'broken' last night works today.

          1 Reply Last reply
          0
          • R RugbyLeague

            Does MasterContext implement IDisposable? If not you can't have it in a using

            M Offline
            M Offline
            Michael J Eber
            wrote on last edited by
            #5

            You must not know anything about Linq to Sql. MasterContext in a Linq to Sql class inherits DataContext which implements IDisposable. Also the documentation for Linq to Sql has almost the first line stating you should always use using() when creating a DataContext.

            R 1 Reply Last reply
            0
            • M Michael J Eber

              You must not know anything about Linq to Sql. MasterContext in a Linq to Sql class inherits DataContext which implements IDisposable. Also the documentation for Linq to Sql has almost the first line stating you should always use using() when creating a DataContext.

              R Offline
              R Offline
              RugbyLeague
              wrote on last edited by
              #6

              You're right, I don't know anything about Linq to SQL ;P

              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