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. LINQ
  4. Linq to SQL Error

Linq to SQL Error

Scheduled Pinned Locked Moved LINQ
databaselinqcsharpregexhelp
8 Posts 3 Posters 40 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.
  • U Offline
    U Offline
    User 11883281
    wrote on last edited by
    #1

    I've got this Code:

    System.Linq.IQueryable fdl = _db.object_localized_1_de.AsQueryable();
    var artNrs = from item in fdl
    where item.bedienungsanweisung.Contains(id)
    && item.article_number != null
    select item.article_number;

    But i get this error:

    Could not find an implementation of the query pattern for source type 'System.Linq.IQueryable'. 'Where' not found. Consider explicitly specifying the type of the range variable 'item'.

    Richard DeemingR I 2 Replies Last reply
    0
    • U User 11883281

      I've got this Code:

      System.Linq.IQueryable fdl = _db.object_localized_1_de.AsQueryable();
      var artNrs = from item in fdl
      where item.bedienungsanweisung.Contains(id)
      && item.article_number != null
      select item.article_number;

      But i get this error:

      Could not find an implementation of the query pattern for source type 'System.Linq.IQueryable'. 'Where' not found. Consider explicitly specifying the type of the range variable 'item'.

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      What type of object does the object_localized_1_de collection contain? Either use the object type as the type parameter for the generic IQueryable<T> interface:

      System.Linq.IQueryable<YOUR_TYPE_HERE> fdl = _db.object_localized_1_de.AsQueryable();

      Or explicitly specify the type in the query:

      var artNrs = from YOUR_TYPE_HERE item in fdl ...

      Or use var to implicitly type the fdl variable:

      var fdl = _db.object_localized_1_de.AsQueryable();

      The first and third options will be identical. The second option will call the Cast method, which could affect the performance.


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      U 1 Reply Last reply
      0
      • Richard DeemingR Richard Deeming

        What type of object does the object_localized_1_de collection contain? Either use the object type as the type parameter for the generic IQueryable<T> interface:

        System.Linq.IQueryable<YOUR_TYPE_HERE> fdl = _db.object_localized_1_de.AsQueryable();

        Or explicitly specify the type in the query:

        var artNrs = from YOUR_TYPE_HERE item in fdl ...

        Or use var to implicitly type the fdl variable:

        var fdl = _db.object_localized_1_de.AsQueryable();

        The first and third options will be identical. The second option will call the Cast method, which could affect the performance.


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        U Offline
        U Offline
        User 11883281
        wrote on last edited by
        #3

        Okay thanks... But now i've this Code:

        for (int i = 0; i < 3; i++)
        {
        var query = _db.object_localized_1_de.AsQueryable();
        if (i == 1) { query = _db.object_localized_1_en.AsQueryable(); }
        if (i == 2) { query = _db.object_localized_1_fr.AsQueryable(); }

        var artNrs = from item in query
        	where item.bedienungsanweisung.Contains(id)
        	&& item.article\_number != null
        	select item.article\_number;
        
        //...
        

        }

        And got this Errors:

        Cannot implicitly convert type 'System.Linq.IQueryable' to 'System.Linq.IQueryable'. An explicit conversion exists (are you missing a cast?)
        Cannot implicitly convert type 'System.Linq.IQueryable' to 'System.Linq.IQueryable'. An explicit conversion exists (are you missing a cast?)

        I don't want to use a cast, may you can help me please?

        Richard DeemingR 1 Reply Last reply
        0
        • U User 11883281

          Okay thanks... But now i've this Code:

          for (int i = 0; i < 3; i++)
          {
          var query = _db.object_localized_1_de.AsQueryable();
          if (i == 1) { query = _db.object_localized_1_en.AsQueryable(); }
          if (i == 2) { query = _db.object_localized_1_fr.AsQueryable(); }

          var artNrs = from item in query
          	where item.bedienungsanweisung.Contains(id)
          	&& item.article\_number != null
          	select item.article\_number;
          
          //...
          

          }

          And got this Errors:

          Cannot implicitly convert type 'System.Linq.IQueryable' to 'System.Linq.IQueryable'. An explicit conversion exists (are you missing a cast?)
          Cannot implicitly convert type 'System.Linq.IQueryable' to 'System.Linq.IQueryable'. An explicit conversion exists (are you missing a cast?)

          I don't want to use a cast, may you can help me please?

          Richard DeemingR Offline
          Richard DeemingR Offline
          Richard Deeming
          wrote on last edited by
          #4

          Your entities will have to implement a common interface, or inherit from a common base class, containing the properties you need to query:

          interface ILocalizedObject
          {
          ?PROPERTY_TYPE_HERE? bedienungsanweisung { get; }
          ?PROPERTY_TYPE_HERE? article_number { get; }
          }

          class object_localized_1_de : ILocalizedObject
          {
          ...
          }

          class object_localized_1_fr : ILocalizedObject
          {
          ...
          }

          class object_localized_1_en : ILocalizedObject
          {
          ...
          }

          You'll then need to use that interface in your variable declaration:

          for (int i = 0; i < 3; i++)
          {
          IQueryable<ILocalizedObject> query = _db.object_localized_1_de.AsQueryable();
          if (i == 1) { query = _db.object_localized_1_en.AsQueryable(); }
          if (i == 2) { query = _db.object_localized_1_fr.AsQueryable(); }

          var artNrs = from item in query
              where item.bedienungsanweisung.Contains(id)
              && item.article\_number != null
              select item.article\_number;
          
          ...
          

          }

          This will work due to generic covariance[^].


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

          U 1 Reply Last reply
          0
          • Richard DeemingR Richard Deeming

            Your entities will have to implement a common interface, or inherit from a common base class, containing the properties you need to query:

            interface ILocalizedObject
            {
            ?PROPERTY_TYPE_HERE? bedienungsanweisung { get; }
            ?PROPERTY_TYPE_HERE? article_number { get; }
            }

            class object_localized_1_de : ILocalizedObject
            {
            ...
            }

            class object_localized_1_fr : ILocalizedObject
            {
            ...
            }

            class object_localized_1_en : ILocalizedObject
            {
            ...
            }

            You'll then need to use that interface in your variable declaration:

            for (int i = 0; i < 3; i++)
            {
            IQueryable<ILocalizedObject> query = _db.object_localized_1_de.AsQueryable();
            if (i == 1) { query = _db.object_localized_1_en.AsQueryable(); }
            if (i == 2) { query = _db.object_localized_1_fr.AsQueryable(); }

            var artNrs = from item in query
                where item.bedienungsanweisung.Contains(id)
                && item.article\_number != null
                select item.article\_number;
            
            ...
            

            }

            This will work due to generic covariance[^].


            "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

            U Offline
            U Offline
            User 11883281
            wrote on last edited by
            #5

            I'm getting this error:

            Cannot implicitly convert type 'System.Linq.IQueryable' to 'System.Linq.IQueryable'. An explicit conversion exists (are you missing a cast?)

            Did I something wrong?

            Richard DeemingR 1 Reply Last reply
            0
            • U User 11883281

              I'm getting this error:

              Cannot implicitly convert type 'System.Linq.IQueryable' to 'System.Linq.IQueryable'. An explicit conversion exists (are you missing a cast?)

              Did I something wrong?

              Richard DeemingR Offline
              Richard DeemingR Offline
              Richard Deeming
              wrote on last edited by
              #6

              Looks like you forgot to make your entity class implement the interface.


              "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

              "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

              U 1 Reply Last reply
              0
              • Richard DeemingR Richard Deeming

                Looks like you forgot to make your entity class implement the interface.


                "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                U Offline
                U Offline
                User 11883281
                wrote on last edited by
                #7

                Yes it works thank you...

                1 Reply Last reply
                0
                • U User 11883281

                  I've got this Code:

                  System.Linq.IQueryable fdl = _db.object_localized_1_de.AsQueryable();
                  var artNrs = from item in fdl
                  where item.bedienungsanweisung.Contains(id)
                  && item.article_number != null
                  select item.article_number;

                  But i get this error:

                  Could not find an implementation of the query pattern for source type 'System.Linq.IQueryable'. 'Where' not found. Consider explicitly specifying the type of the range variable 'item'.

                  I Offline
                  I Offline
                  ip address
                  wrote on last edited by
                  #8

                  :thumbsup: Super! Thanks!

                  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