none
Unable to convert the type "system.collection.generic.ienumerable < SeismicSocket.mymodel >" implicitly converts to "system.collection.concurrent. ConcurrentBag < SeismicSocket.mymodel >".

    Question

  • Unable to convert the type "system.collection.generic.ienumerable < SeismicSocket.mymodel >" implicitly converts to "system.collection.concurrent. ConcurrentBag < SeismicSocket.mymodel >". There is an explicit transformation (is there a lack of forced conversion?).


    please verify my account


    • Edited by lctk Sunday, April 30, 2017 2:35 AM
    Sunday, April 30, 2017 2:34 AM

Answers

  • Try this:

       var q = from c in ... select c;
       ConcurrentBag<MyModel> temList = new ConcurrentBag<MyModel>(q);

    Sunday, April 30, 2017 7:29 PM
  • You can't convert objects across two different namespaces, even if the object is the same in both namespaces.

    "system.collection.generic.ienumerable < SeismicSocket.mymodel >"

    "system.collection.generic.ienumerable  is one namespace

    "system.collection.concurrent. ConcurrentBag < SeismicSocket.mymodel >".

    system.collection.concurrent. ConcurrentBag is the other namespace. .Net is not going to allow the cast.

    The best you can do is get system.collection.generic.ienumerable < SeismicSocket.mymodel >" objects out on a query and in a forloop get eact object and map properties over to system.collection.concurrent. ConcurrentBag < SeismicSocket.mymodel >".

    or

    do a new shape, a projection,  and make the system.collection.concurrent. ConcurrentBag < SeismicSocket.mymodel >" on the fly.

    Sunday, April 30, 2017 8:28 PM

All replies

  • Try this:

       var q = from c in ... select c;
       ConcurrentBag<MyModel> temList = new ConcurrentBag<MyModel>(q);

    Sunday, April 30, 2017 7:29 PM
  • You can't convert objects across two different namespaces, even if the object is the same in both namespaces.

    "system.collection.generic.ienumerable < SeismicSocket.mymodel >"

    "system.collection.generic.ienumerable  is one namespace

    "system.collection.concurrent. ConcurrentBag < SeismicSocket.mymodel >".

    system.collection.concurrent. ConcurrentBag is the other namespace. .Net is not going to allow the cast.

    The best you can do is get system.collection.generic.ienumerable < SeismicSocket.mymodel >" objects out on a query and in a forloop get eact object and map properties over to system.collection.concurrent. ConcurrentBag < SeismicSocket.mymodel >".

    or

    do a new shape, a projection,  and make the system.collection.concurrent. ConcurrentBag < SeismicSocket.mymodel >" on the fly.

    Sunday, April 30, 2017 8:28 PM