How do I add a new record to an IQueryable variable?











up vote
22
down vote

favorite
5












The IQueryable results is queried from my db using LINQ, How do I add a new record to the IQueryable result.










share|improve this question
























  • Depends on what "IQueryable result" is.
    – Gert Arnold
    Nov 18 at 9:23















up vote
22
down vote

favorite
5












The IQueryable results is queried from my db using LINQ, How do I add a new record to the IQueryable result.










share|improve this question
























  • Depends on what "IQueryable result" is.
    – Gert Arnold
    Nov 18 at 9:23













up vote
22
down vote

favorite
5









up vote
22
down vote

favorite
5






5





The IQueryable results is queried from my db using LINQ, How do I add a new record to the IQueryable result.










share|improve this question















The IQueryable results is queried from my db using LINQ, How do I add a new record to the IQueryable result.







linq iqueryable






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 11 '15 at 14:31









Dan Beaulieu

12.7k1078107




12.7k1078107










asked Jan 12 '09 at 7:50







silent200



















  • Depends on what "IQueryable result" is.
    – Gert Arnold
    Nov 18 at 9:23


















  • Depends on what "IQueryable result" is.
    – Gert Arnold
    Nov 18 at 9:23
















Depends on what "IQueryable result" is.
– Gert Arnold
Nov 18 at 9:23




Depends on what "IQueryable result" is.
– Gert Arnold
Nov 18 at 9:23












8 Answers
8






active

oldest

votes

















up vote
36
down vote













Do you want to add it to the database, or just to the list of results that other things like databinding will use?



If it's the former, you'll need to use the normal add operation for whatever kind of LINQ you're using, but to the table representation rather than the IQueryable. Queries only read data.



If it's the latter, use Enumerable.Concat to concatenate your existing sequence (the IQueryable) with a new one containing your extra entries (an array would do fine here, or a list), and use the result for binding etc. It's probably worth using AsEnumerable() first to make sure that Enumerable is used instead of Queryable. For example:



IQueryable<string> names = [...];
names = names.AsEnumerable().Concat(new { "(None)", "(Add new)" });





share|improve this answer




























    up vote
    11
    down vote













    You should first convert it to List;



    IQueryable<int> foo = new SomeQueryable<int<();
    List<int> list = foo.ToList();
    list.Add(5);


    or by using Concat



    IQueryable<int> foo = new SomeQueryable<int<();
    foo = foo.Concat(new int{5});


    EDIT: sure you have to reassign foo.






    share|improve this answer























    • But my IQueryable variable has two different data types, the SexCode field is an integer, and SexName is a string, so I can't specify the datatype.
      – silent200
      Jan 12 '09 at 9:26










    • See my new answer. It would help.
      – Ali Ersöz
      Jan 12 '09 at 9:27






    • 5




      you can't do this: IQueryable<int> foo = new IQueryable<int>(); IQueryable is an abstract class.
      – Cacho Santa
      Jan 20 '12 at 19:06








    • 1




      sure you cannot initialize an abstract class. it is my mistake. but assume that foo is an IQueryable<int> instead.
      – Ali Ersöz
      May 2 '12 at 17:47


















    up vote
    4
    down vote













    The simple answer is that unless you add the record to the underlying datastore that the Iqueryable is querying, you can't add a new record into an IQueryable. So if you are using LinqToSql then you would have to add a row into the table that the IQueryable was querying in order to "add" a row into the IQueryable.



    Remember that an IQueryable is not a result set, it is a query. Until you use something like .ToList() the IQueryable will not evaluate a result set and more importantly, the IQueryable doesn't hang on to that result set. It creates a list and puts the results into in instead. So that means that if you call ToList() on an Iqueryable twice, it will go off and query the database twice. It doesn't care that it might be inefficient.



    So, if you look at the examples that others have used above, a simple change of AsEnumerable() to ToList() will most likely fix your problems.



    Something like:



    dcDataContext db = new dcDataContext();
    var query = from c in db.tblSexes
    select new { c.SexCode, c.SexName };

    var results = query.ToList().Concat(new { new { SexCode = -1, SexName = "Please select your Gender" } });

    //or even better now that it's a list
    var results = query.ToList().Add(new { SexCode = -1, SexName = "Please select your Gender" });

    SelectList sliSex = new SelectList(results, "SexCode", "SexName");





    share|improve this answer




























      up vote
      3
      down vote













      It might be a very old question, I would like to add more explanation and sample here



      if you use IQueryable<YourObject> , you must convert it to IEnumerable<YourObject> first




      addition detail about IEnumerable:



      Returning IEnumerable<T> vs. IQueryable<T>




      by



      IQueryable<YourObject> iqueryResult = // ..... your LinQ or whatever
      IEnumerable<YourObject> enumResult = iqueryResult.AsEnumerable();


      then, to add you can do it by



      enumResult = enumResult.Concat(new {new YourObject()
      {
      //....
      }
      });


      sample of real code



      var iquery_QRDTR = from rrp in P_QCDTR
      select new WebRequestData
      {
      ros_chk_id = rrp.CHECKIN_ID,
      ros_img = rrp.EMPLOYEE_ASSOCIATE.IMAGE_URL
      };

      var enum_QRDTR = iquery_QRDTR.AsEnumerable();

      enum_QRDTR = enum_QRDTR.Concat(new {new WebRequestData()
      {
      ros_chk_id = 16,
      ros_img = "http://link.to.image/profile.jpg"
      } });





      share|improve this answer






























        up vote
        1
        down vote













        Try this:



        var query = from c in db.clClinics select c; 

        var results = query.ToList().Concat(new clClinic { new clClinic()});





        share|improve this answer






























          up vote
          0
          down vote













          Because the results is IQueryable you should cast to it



            dcDataContext db = new dcDataContext();
          var results = from c in db.tblSexes
          select new { c.SexCode, c.SexName };
          results = results.AsEnumerable().Concat(new { new { SexCode = -1, SexName = "Please select your Gender"} }).AsQueryable();
          SelectList sliSex = new SelectList(results, "SexCode", "SexName");


          Or without any casting




          results = results.Union(new { new {
          SexCode = -1, SexName = "Please select
          your Gender"} })







          share|improve this answer





















          • Sorry, but I tried your code, but I still got errors.
            – silent200
            Jan 12 '09 at 9:42










          • can you paste your latest code because I coded my answer and it works
            – Dincer Uyav
            Jan 12 '09 at 9:44










          • That is what I mentioned. I guess he forgot to define property names explicitly.
            – Ali Ersöz
            Jan 12 '09 at 9:45










          • Thanks, but I got a new error: The type arguments for method 'System.Linq.Queryable.Union<TSource>(System.Linq.IQueryable<TSource>, System.Collections.Generic.IEnumerable<TSource>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
            – silent200
            Jan 12 '09 at 9:46










          • Sure, 'she' is an option too :)
            – Ali Ersöz
            Jan 12 '09 at 9:47


















          up vote
          0
          down vote













          Explicitly set properties for anonymous types. Try This:



          dcDataContext db = new dcDataContext();
          var results = from c in db.tblSexes
          select new { c.SexCode, c.SexName };
          results = results.AsEnumerable().Concat(new { new { SexCode = -1, SexName = "Please select your Gender"} });
          SelectList sliSex = new SelectList(results, "SexCode", "SexName");


          Edit: You have to point the exact types of you properties. I mean if it is int you have to point that it is. I guess SexCode is a 'long' and by default -1 is an 'int'. If you cast -1 to long(or the type of SexCode) the problem will be solved.



          Here is the exact solution if SexCode's type is long.



          dcDataContext db = new dcDataContext();
          var results = from c in db.tblSexes
          select new { c.SexCode, c.SexName };
          results = results.Concat(new { new { SexCode = -1L, SexName = "Please select your Gender"} });
          SelectList sliSex = new SelectList(results, "SexCode", "SexName");





          share|improve this answer























          • I really appreciate your help, but it still doesn't work, I got the error msg: The type arguments for method 'System.Linq.Enumerable.Concat<TSource>, System.Collections.Generic.IEnumerable<TSource>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
            – silent200
            Jan 12 '09 at 9:34










          • Your welcome :) But I think you forgot to give the property names. Try 'new { new { SexCode = -1, SexName = "Please select your Gender"} }' not 'new { new { -1, "Please select your Gender"} }'. The error mentions that!
            – Ali Ersöz
            Jan 12 '09 at 9:41










          • Tried this one, but still won't work :o( Error: The type arguments for method 'System.Linq.Enumerable.Concat<TSource>(System.Collections.Generic.IEnumerable<TSource>, System.Collections.Generic.IEnumerable<TSource>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
            – silent200
            Jan 12 '09 at 9:52










          • Can you post the code that you wrote to here?
            – Ali Ersöz
            Jan 12 '09 at 9:54










          • Hi, I just updated my code, pls see the "answer" I posted above.
            – silent200
            Jan 12 '09 at 10:05


















          up vote
          0
          down vote













          You can use union



          IQueryable<int> foo = new SomeQueryable<int>();
          IQueryable<int> foo2 = new SomeQueryable<int>();
          foo = foo.Union(foo2);





          share|improve this answer










          New contributor




          Nurlan T is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.


















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














             

            draft saved


            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f434737%2fhow-do-i-add-a-new-record-to-an-iqueryable-variable%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown
























            8 Answers
            8






            active

            oldest

            votes








            8 Answers
            8






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            36
            down vote













            Do you want to add it to the database, or just to the list of results that other things like databinding will use?



            If it's the former, you'll need to use the normal add operation for whatever kind of LINQ you're using, but to the table representation rather than the IQueryable. Queries only read data.



            If it's the latter, use Enumerable.Concat to concatenate your existing sequence (the IQueryable) with a new one containing your extra entries (an array would do fine here, or a list), and use the result for binding etc. It's probably worth using AsEnumerable() first to make sure that Enumerable is used instead of Queryable. For example:



            IQueryable<string> names = [...];
            names = names.AsEnumerable().Concat(new { "(None)", "(Add new)" });





            share|improve this answer

























              up vote
              36
              down vote













              Do you want to add it to the database, or just to the list of results that other things like databinding will use?



              If it's the former, you'll need to use the normal add operation for whatever kind of LINQ you're using, but to the table representation rather than the IQueryable. Queries only read data.



              If it's the latter, use Enumerable.Concat to concatenate your existing sequence (the IQueryable) with a new one containing your extra entries (an array would do fine here, or a list), and use the result for binding etc. It's probably worth using AsEnumerable() first to make sure that Enumerable is used instead of Queryable. For example:



              IQueryable<string> names = [...];
              names = names.AsEnumerable().Concat(new { "(None)", "(Add new)" });





              share|improve this answer























                up vote
                36
                down vote










                up vote
                36
                down vote









                Do you want to add it to the database, or just to the list of results that other things like databinding will use?



                If it's the former, you'll need to use the normal add operation for whatever kind of LINQ you're using, but to the table representation rather than the IQueryable. Queries only read data.



                If it's the latter, use Enumerable.Concat to concatenate your existing sequence (the IQueryable) with a new one containing your extra entries (an array would do fine here, or a list), and use the result for binding etc. It's probably worth using AsEnumerable() first to make sure that Enumerable is used instead of Queryable. For example:



                IQueryable<string> names = [...];
                names = names.AsEnumerable().Concat(new { "(None)", "(Add new)" });





                share|improve this answer












                Do you want to add it to the database, or just to the list of results that other things like databinding will use?



                If it's the former, you'll need to use the normal add operation for whatever kind of LINQ you're using, but to the table representation rather than the IQueryable. Queries only read data.



                If it's the latter, use Enumerable.Concat to concatenate your existing sequence (the IQueryable) with a new one containing your extra entries (an array would do fine here, or a list), and use the result for binding etc. It's probably worth using AsEnumerable() first to make sure that Enumerable is used instead of Queryable. For example:



                IQueryable<string> names = [...];
                names = names.AsEnumerable().Concat(new { "(None)", "(Add new)" });






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 12 '09 at 7:58









                Jon Skeet

                1069k67178348374




                1069k67178348374
























                    up vote
                    11
                    down vote













                    You should first convert it to List;



                    IQueryable<int> foo = new SomeQueryable<int<();
                    List<int> list = foo.ToList();
                    list.Add(5);


                    or by using Concat



                    IQueryable<int> foo = new SomeQueryable<int<();
                    foo = foo.Concat(new int{5});


                    EDIT: sure you have to reassign foo.






                    share|improve this answer























                    • But my IQueryable variable has two different data types, the SexCode field is an integer, and SexName is a string, so I can't specify the datatype.
                      – silent200
                      Jan 12 '09 at 9:26










                    • See my new answer. It would help.
                      – Ali Ersöz
                      Jan 12 '09 at 9:27






                    • 5




                      you can't do this: IQueryable<int> foo = new IQueryable<int>(); IQueryable is an abstract class.
                      – Cacho Santa
                      Jan 20 '12 at 19:06








                    • 1




                      sure you cannot initialize an abstract class. it is my mistake. but assume that foo is an IQueryable<int> instead.
                      – Ali Ersöz
                      May 2 '12 at 17:47















                    up vote
                    11
                    down vote













                    You should first convert it to List;



                    IQueryable<int> foo = new SomeQueryable<int<();
                    List<int> list = foo.ToList();
                    list.Add(5);


                    or by using Concat



                    IQueryable<int> foo = new SomeQueryable<int<();
                    foo = foo.Concat(new int{5});


                    EDIT: sure you have to reassign foo.






                    share|improve this answer























                    • But my IQueryable variable has two different data types, the SexCode field is an integer, and SexName is a string, so I can't specify the datatype.
                      – silent200
                      Jan 12 '09 at 9:26










                    • See my new answer. It would help.
                      – Ali Ersöz
                      Jan 12 '09 at 9:27






                    • 5




                      you can't do this: IQueryable<int> foo = new IQueryable<int>(); IQueryable is an abstract class.
                      – Cacho Santa
                      Jan 20 '12 at 19:06








                    • 1




                      sure you cannot initialize an abstract class. it is my mistake. but assume that foo is an IQueryable<int> instead.
                      – Ali Ersöz
                      May 2 '12 at 17:47













                    up vote
                    11
                    down vote










                    up vote
                    11
                    down vote









                    You should first convert it to List;



                    IQueryable<int> foo = new SomeQueryable<int<();
                    List<int> list = foo.ToList();
                    list.Add(5);


                    or by using Concat



                    IQueryable<int> foo = new SomeQueryable<int<();
                    foo = foo.Concat(new int{5});


                    EDIT: sure you have to reassign foo.






                    share|improve this answer














                    You should first convert it to List;



                    IQueryable<int> foo = new SomeQueryable<int<();
                    List<int> list = foo.ToList();
                    list.Add(5);


                    or by using Concat



                    IQueryable<int> foo = new SomeQueryable<int<();
                    foo = foo.Concat(new int{5});


                    EDIT: sure you have to reassign foo.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited May 2 '12 at 17:49

























                    answered Jan 12 '09 at 7:55









                    Ali Ersöz

                    11.7k84561




                    11.7k84561












                    • But my IQueryable variable has two different data types, the SexCode field is an integer, and SexName is a string, so I can't specify the datatype.
                      – silent200
                      Jan 12 '09 at 9:26










                    • See my new answer. It would help.
                      – Ali Ersöz
                      Jan 12 '09 at 9:27






                    • 5




                      you can't do this: IQueryable<int> foo = new IQueryable<int>(); IQueryable is an abstract class.
                      – Cacho Santa
                      Jan 20 '12 at 19:06








                    • 1




                      sure you cannot initialize an abstract class. it is my mistake. but assume that foo is an IQueryable<int> instead.
                      – Ali Ersöz
                      May 2 '12 at 17:47


















                    • But my IQueryable variable has two different data types, the SexCode field is an integer, and SexName is a string, so I can't specify the datatype.
                      – silent200
                      Jan 12 '09 at 9:26










                    • See my new answer. It would help.
                      – Ali Ersöz
                      Jan 12 '09 at 9:27






                    • 5




                      you can't do this: IQueryable<int> foo = new IQueryable<int>(); IQueryable is an abstract class.
                      – Cacho Santa
                      Jan 20 '12 at 19:06








                    • 1




                      sure you cannot initialize an abstract class. it is my mistake. but assume that foo is an IQueryable<int> instead.
                      – Ali Ersöz
                      May 2 '12 at 17:47
















                    But my IQueryable variable has two different data types, the SexCode field is an integer, and SexName is a string, so I can't specify the datatype.
                    – silent200
                    Jan 12 '09 at 9:26




                    But my IQueryable variable has two different data types, the SexCode field is an integer, and SexName is a string, so I can't specify the datatype.
                    – silent200
                    Jan 12 '09 at 9:26












                    See my new answer. It would help.
                    – Ali Ersöz
                    Jan 12 '09 at 9:27




                    See my new answer. It would help.
                    – Ali Ersöz
                    Jan 12 '09 at 9:27




                    5




                    5




                    you can't do this: IQueryable<int> foo = new IQueryable<int>(); IQueryable is an abstract class.
                    – Cacho Santa
                    Jan 20 '12 at 19:06






                    you can't do this: IQueryable<int> foo = new IQueryable<int>(); IQueryable is an abstract class.
                    – Cacho Santa
                    Jan 20 '12 at 19:06






                    1




                    1




                    sure you cannot initialize an abstract class. it is my mistake. but assume that foo is an IQueryable<int> instead.
                    – Ali Ersöz
                    May 2 '12 at 17:47




                    sure you cannot initialize an abstract class. it is my mistake. but assume that foo is an IQueryable<int> instead.
                    – Ali Ersöz
                    May 2 '12 at 17:47










                    up vote
                    4
                    down vote













                    The simple answer is that unless you add the record to the underlying datastore that the Iqueryable is querying, you can't add a new record into an IQueryable. So if you are using LinqToSql then you would have to add a row into the table that the IQueryable was querying in order to "add" a row into the IQueryable.



                    Remember that an IQueryable is not a result set, it is a query. Until you use something like .ToList() the IQueryable will not evaluate a result set and more importantly, the IQueryable doesn't hang on to that result set. It creates a list and puts the results into in instead. So that means that if you call ToList() on an Iqueryable twice, it will go off and query the database twice. It doesn't care that it might be inefficient.



                    So, if you look at the examples that others have used above, a simple change of AsEnumerable() to ToList() will most likely fix your problems.



                    Something like:



                    dcDataContext db = new dcDataContext();
                    var query = from c in db.tblSexes
                    select new { c.SexCode, c.SexName };

                    var results = query.ToList().Concat(new { new { SexCode = -1, SexName = "Please select your Gender" } });

                    //or even better now that it's a list
                    var results = query.ToList().Add(new { SexCode = -1, SexName = "Please select your Gender" });

                    SelectList sliSex = new SelectList(results, "SexCode", "SexName");





                    share|improve this answer

























                      up vote
                      4
                      down vote













                      The simple answer is that unless you add the record to the underlying datastore that the Iqueryable is querying, you can't add a new record into an IQueryable. So if you are using LinqToSql then you would have to add a row into the table that the IQueryable was querying in order to "add" a row into the IQueryable.



                      Remember that an IQueryable is not a result set, it is a query. Until you use something like .ToList() the IQueryable will not evaluate a result set and more importantly, the IQueryable doesn't hang on to that result set. It creates a list and puts the results into in instead. So that means that if you call ToList() on an Iqueryable twice, it will go off and query the database twice. It doesn't care that it might be inefficient.



                      So, if you look at the examples that others have used above, a simple change of AsEnumerable() to ToList() will most likely fix your problems.



                      Something like:



                      dcDataContext db = new dcDataContext();
                      var query = from c in db.tblSexes
                      select new { c.SexCode, c.SexName };

                      var results = query.ToList().Concat(new { new { SexCode = -1, SexName = "Please select your Gender" } });

                      //or even better now that it's a list
                      var results = query.ToList().Add(new { SexCode = -1, SexName = "Please select your Gender" });

                      SelectList sliSex = new SelectList(results, "SexCode", "SexName");





                      share|improve this answer























                        up vote
                        4
                        down vote










                        up vote
                        4
                        down vote









                        The simple answer is that unless you add the record to the underlying datastore that the Iqueryable is querying, you can't add a new record into an IQueryable. So if you are using LinqToSql then you would have to add a row into the table that the IQueryable was querying in order to "add" a row into the IQueryable.



                        Remember that an IQueryable is not a result set, it is a query. Until you use something like .ToList() the IQueryable will not evaluate a result set and more importantly, the IQueryable doesn't hang on to that result set. It creates a list and puts the results into in instead. So that means that if you call ToList() on an Iqueryable twice, it will go off and query the database twice. It doesn't care that it might be inefficient.



                        So, if you look at the examples that others have used above, a simple change of AsEnumerable() to ToList() will most likely fix your problems.



                        Something like:



                        dcDataContext db = new dcDataContext();
                        var query = from c in db.tblSexes
                        select new { c.SexCode, c.SexName };

                        var results = query.ToList().Concat(new { new { SexCode = -1, SexName = "Please select your Gender" } });

                        //or even better now that it's a list
                        var results = query.ToList().Add(new { SexCode = -1, SexName = "Please select your Gender" });

                        SelectList sliSex = new SelectList(results, "SexCode", "SexName");





                        share|improve this answer












                        The simple answer is that unless you add the record to the underlying datastore that the Iqueryable is querying, you can't add a new record into an IQueryable. So if you are using LinqToSql then you would have to add a row into the table that the IQueryable was querying in order to "add" a row into the IQueryable.



                        Remember that an IQueryable is not a result set, it is a query. Until you use something like .ToList() the IQueryable will not evaluate a result set and more importantly, the IQueryable doesn't hang on to that result set. It creates a list and puts the results into in instead. So that means that if you call ToList() on an Iqueryable twice, it will go off and query the database twice. It doesn't care that it might be inefficient.



                        So, if you look at the examples that others have used above, a simple change of AsEnumerable() to ToList() will most likely fix your problems.



                        Something like:



                        dcDataContext db = new dcDataContext();
                        var query = from c in db.tblSexes
                        select new { c.SexCode, c.SexName };

                        var results = query.ToList().Concat(new { new { SexCode = -1, SexName = "Please select your Gender" } });

                        //or even better now that it's a list
                        var results = query.ToList().Add(new { SexCode = -1, SexName = "Please select your Gender" });

                        SelectList sliSex = new SelectList(results, "SexCode", "SexName");






                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Feb 18 '09 at 3:21









                        Jero

                        1393




                        1393






















                            up vote
                            3
                            down vote













                            It might be a very old question, I would like to add more explanation and sample here



                            if you use IQueryable<YourObject> , you must convert it to IEnumerable<YourObject> first




                            addition detail about IEnumerable:



                            Returning IEnumerable<T> vs. IQueryable<T>




                            by



                            IQueryable<YourObject> iqueryResult = // ..... your LinQ or whatever
                            IEnumerable<YourObject> enumResult = iqueryResult.AsEnumerable();


                            then, to add you can do it by



                            enumResult = enumResult.Concat(new {new YourObject()
                            {
                            //....
                            }
                            });


                            sample of real code



                            var iquery_QRDTR = from rrp in P_QCDTR
                            select new WebRequestData
                            {
                            ros_chk_id = rrp.CHECKIN_ID,
                            ros_img = rrp.EMPLOYEE_ASSOCIATE.IMAGE_URL
                            };

                            var enum_QRDTR = iquery_QRDTR.AsEnumerable();

                            enum_QRDTR = enum_QRDTR.Concat(new {new WebRequestData()
                            {
                            ros_chk_id = 16,
                            ros_img = "http://link.to.image/profile.jpg"
                            } });





                            share|improve this answer



























                              up vote
                              3
                              down vote













                              It might be a very old question, I would like to add more explanation and sample here



                              if you use IQueryable<YourObject> , you must convert it to IEnumerable<YourObject> first




                              addition detail about IEnumerable:



                              Returning IEnumerable<T> vs. IQueryable<T>




                              by



                              IQueryable<YourObject> iqueryResult = // ..... your LinQ or whatever
                              IEnumerable<YourObject> enumResult = iqueryResult.AsEnumerable();


                              then, to add you can do it by



                              enumResult = enumResult.Concat(new {new YourObject()
                              {
                              //....
                              }
                              });


                              sample of real code



                              var iquery_QRDTR = from rrp in P_QCDTR
                              select new WebRequestData
                              {
                              ros_chk_id = rrp.CHECKIN_ID,
                              ros_img = rrp.EMPLOYEE_ASSOCIATE.IMAGE_URL
                              };

                              var enum_QRDTR = iquery_QRDTR.AsEnumerable();

                              enum_QRDTR = enum_QRDTR.Concat(new {new WebRequestData()
                              {
                              ros_chk_id = 16,
                              ros_img = "http://link.to.image/profile.jpg"
                              } });





                              share|improve this answer

























                                up vote
                                3
                                down vote










                                up vote
                                3
                                down vote









                                It might be a very old question, I would like to add more explanation and sample here



                                if you use IQueryable<YourObject> , you must convert it to IEnumerable<YourObject> first




                                addition detail about IEnumerable:



                                Returning IEnumerable<T> vs. IQueryable<T>




                                by



                                IQueryable<YourObject> iqueryResult = // ..... your LinQ or whatever
                                IEnumerable<YourObject> enumResult = iqueryResult.AsEnumerable();


                                then, to add you can do it by



                                enumResult = enumResult.Concat(new {new YourObject()
                                {
                                //....
                                }
                                });


                                sample of real code



                                var iquery_QRDTR = from rrp in P_QCDTR
                                select new WebRequestData
                                {
                                ros_chk_id = rrp.CHECKIN_ID,
                                ros_img = rrp.EMPLOYEE_ASSOCIATE.IMAGE_URL
                                };

                                var enum_QRDTR = iquery_QRDTR.AsEnumerable();

                                enum_QRDTR = enum_QRDTR.Concat(new {new WebRequestData()
                                {
                                ros_chk_id = 16,
                                ros_img = "http://link.to.image/profile.jpg"
                                } });





                                share|improve this answer














                                It might be a very old question, I would like to add more explanation and sample here



                                if you use IQueryable<YourObject> , you must convert it to IEnumerable<YourObject> first




                                addition detail about IEnumerable:



                                Returning IEnumerable<T> vs. IQueryable<T>




                                by



                                IQueryable<YourObject> iqueryResult = // ..... your LinQ or whatever
                                IEnumerable<YourObject> enumResult = iqueryResult.AsEnumerable();


                                then, to add you can do it by



                                enumResult = enumResult.Concat(new {new YourObject()
                                {
                                //....
                                }
                                });


                                sample of real code



                                var iquery_QRDTR = from rrp in P_QCDTR
                                select new WebRequestData
                                {
                                ros_chk_id = rrp.CHECKIN_ID,
                                ros_img = rrp.EMPLOYEE_ASSOCIATE.IMAGE_URL
                                };

                                var enum_QRDTR = iquery_QRDTR.AsEnumerable();

                                enum_QRDTR = enum_QRDTR.Concat(new {new WebRequestData()
                                {
                                ros_chk_id = 16,
                                ros_img = "http://link.to.image/profile.jpg"
                                } });






                                share|improve this answer














                                share|improve this answer



                                share|improve this answer








                                edited May 23 '17 at 10:31









                                Community

                                11




                                11










                                answered Sep 15 '15 at 8:32









                                Sruit A.Suk

                                4,76864154




                                4,76864154






















                                    up vote
                                    1
                                    down vote













                                    Try this:



                                    var query = from c in db.clClinics select c; 

                                    var results = query.ToList().Concat(new clClinic { new clClinic()});





                                    share|improve this answer



























                                      up vote
                                      1
                                      down vote













                                      Try this:



                                      var query = from c in db.clClinics select c; 

                                      var results = query.ToList().Concat(new clClinic { new clClinic()});





                                      share|improve this answer

























                                        up vote
                                        1
                                        down vote










                                        up vote
                                        1
                                        down vote









                                        Try this:



                                        var query = from c in db.clClinics select c; 

                                        var results = query.ToList().Concat(new clClinic { new clClinic()});





                                        share|improve this answer














                                        Try this:



                                        var query = from c in db.clClinics select c; 

                                        var results = query.ToList().Concat(new clClinic { new clClinic()});






                                        share|improve this answer














                                        share|improve this answer



                                        share|improve this answer








                                        edited Nov 20 '11 at 19:16

























                                        answered Nov 20 '11 at 19:13









                                        ayman

                                        112




                                        112






















                                            up vote
                                            0
                                            down vote













                                            Because the results is IQueryable you should cast to it



                                              dcDataContext db = new dcDataContext();
                                            var results = from c in db.tblSexes
                                            select new { c.SexCode, c.SexName };
                                            results = results.AsEnumerable().Concat(new { new { SexCode = -1, SexName = "Please select your Gender"} }).AsQueryable();
                                            SelectList sliSex = new SelectList(results, "SexCode", "SexName");


                                            Or without any casting




                                            results = results.Union(new { new {
                                            SexCode = -1, SexName = "Please select
                                            your Gender"} })







                                            share|improve this answer





















                                            • Sorry, but I tried your code, but I still got errors.
                                              – silent200
                                              Jan 12 '09 at 9:42










                                            • can you paste your latest code because I coded my answer and it works
                                              – Dincer Uyav
                                              Jan 12 '09 at 9:44










                                            • That is what I mentioned. I guess he forgot to define property names explicitly.
                                              – Ali Ersöz
                                              Jan 12 '09 at 9:45










                                            • Thanks, but I got a new error: The type arguments for method 'System.Linq.Queryable.Union<TSource>(System.Linq.IQueryable<TSource>, System.Collections.Generic.IEnumerable<TSource>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
                                              – silent200
                                              Jan 12 '09 at 9:46










                                            • Sure, 'she' is an option too :)
                                              – Ali Ersöz
                                              Jan 12 '09 at 9:47















                                            up vote
                                            0
                                            down vote













                                            Because the results is IQueryable you should cast to it



                                              dcDataContext db = new dcDataContext();
                                            var results = from c in db.tblSexes
                                            select new { c.SexCode, c.SexName };
                                            results = results.AsEnumerable().Concat(new { new { SexCode = -1, SexName = "Please select your Gender"} }).AsQueryable();
                                            SelectList sliSex = new SelectList(results, "SexCode", "SexName");


                                            Or without any casting




                                            results = results.Union(new { new {
                                            SexCode = -1, SexName = "Please select
                                            your Gender"} })







                                            share|improve this answer





















                                            • Sorry, but I tried your code, but I still got errors.
                                              – silent200
                                              Jan 12 '09 at 9:42










                                            • can you paste your latest code because I coded my answer and it works
                                              – Dincer Uyav
                                              Jan 12 '09 at 9:44










                                            • That is what I mentioned. I guess he forgot to define property names explicitly.
                                              – Ali Ersöz
                                              Jan 12 '09 at 9:45










                                            • Thanks, but I got a new error: The type arguments for method 'System.Linq.Queryable.Union<TSource>(System.Linq.IQueryable<TSource>, System.Collections.Generic.IEnumerable<TSource>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
                                              – silent200
                                              Jan 12 '09 at 9:46










                                            • Sure, 'she' is an option too :)
                                              – Ali Ersöz
                                              Jan 12 '09 at 9:47













                                            up vote
                                            0
                                            down vote










                                            up vote
                                            0
                                            down vote









                                            Because the results is IQueryable you should cast to it



                                              dcDataContext db = new dcDataContext();
                                            var results = from c in db.tblSexes
                                            select new { c.SexCode, c.SexName };
                                            results = results.AsEnumerable().Concat(new { new { SexCode = -1, SexName = "Please select your Gender"} }).AsQueryable();
                                            SelectList sliSex = new SelectList(results, "SexCode", "SexName");


                                            Or without any casting




                                            results = results.Union(new { new {
                                            SexCode = -1, SexName = "Please select
                                            your Gender"} })







                                            share|improve this answer












                                            Because the results is IQueryable you should cast to it



                                              dcDataContext db = new dcDataContext();
                                            var results = from c in db.tblSexes
                                            select new { c.SexCode, c.SexName };
                                            results = results.AsEnumerable().Concat(new { new { SexCode = -1, SexName = "Please select your Gender"} }).AsQueryable();
                                            SelectList sliSex = new SelectList(results, "SexCode", "SexName");


                                            Or without any casting




                                            results = results.Union(new { new {
                                            SexCode = -1, SexName = "Please select
                                            your Gender"} })








                                            share|improve this answer












                                            share|improve this answer



                                            share|improve this answer










                                            answered Jan 12 '09 at 9:40









                                            Dincer Uyav

                                            4819




                                            4819












                                            • Sorry, but I tried your code, but I still got errors.
                                              – silent200
                                              Jan 12 '09 at 9:42










                                            • can you paste your latest code because I coded my answer and it works
                                              – Dincer Uyav
                                              Jan 12 '09 at 9:44










                                            • That is what I mentioned. I guess he forgot to define property names explicitly.
                                              – Ali Ersöz
                                              Jan 12 '09 at 9:45










                                            • Thanks, but I got a new error: The type arguments for method 'System.Linq.Queryable.Union<TSource>(System.Linq.IQueryable<TSource>, System.Collections.Generic.IEnumerable<TSource>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
                                              – silent200
                                              Jan 12 '09 at 9:46










                                            • Sure, 'she' is an option too :)
                                              – Ali Ersöz
                                              Jan 12 '09 at 9:47


















                                            • Sorry, but I tried your code, but I still got errors.
                                              – silent200
                                              Jan 12 '09 at 9:42










                                            • can you paste your latest code because I coded my answer and it works
                                              – Dincer Uyav
                                              Jan 12 '09 at 9:44










                                            • That is what I mentioned. I guess he forgot to define property names explicitly.
                                              – Ali Ersöz
                                              Jan 12 '09 at 9:45










                                            • Thanks, but I got a new error: The type arguments for method 'System.Linq.Queryable.Union<TSource>(System.Linq.IQueryable<TSource>, System.Collections.Generic.IEnumerable<TSource>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
                                              – silent200
                                              Jan 12 '09 at 9:46










                                            • Sure, 'she' is an option too :)
                                              – Ali Ersöz
                                              Jan 12 '09 at 9:47
















                                            Sorry, but I tried your code, but I still got errors.
                                            – silent200
                                            Jan 12 '09 at 9:42




                                            Sorry, but I tried your code, but I still got errors.
                                            – silent200
                                            Jan 12 '09 at 9:42












                                            can you paste your latest code because I coded my answer and it works
                                            – Dincer Uyav
                                            Jan 12 '09 at 9:44




                                            can you paste your latest code because I coded my answer and it works
                                            – Dincer Uyav
                                            Jan 12 '09 at 9:44












                                            That is what I mentioned. I guess he forgot to define property names explicitly.
                                            – Ali Ersöz
                                            Jan 12 '09 at 9:45




                                            That is what I mentioned. I guess he forgot to define property names explicitly.
                                            – Ali Ersöz
                                            Jan 12 '09 at 9:45












                                            Thanks, but I got a new error: The type arguments for method 'System.Linq.Queryable.Union<TSource>(System.Linq.IQueryable<TSource>, System.Collections.Generic.IEnumerable<TSource>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
                                            – silent200
                                            Jan 12 '09 at 9:46




                                            Thanks, but I got a new error: The type arguments for method 'System.Linq.Queryable.Union<TSource>(System.Linq.IQueryable<TSource>, System.Collections.Generic.IEnumerable<TSource>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
                                            – silent200
                                            Jan 12 '09 at 9:46












                                            Sure, 'she' is an option too :)
                                            – Ali Ersöz
                                            Jan 12 '09 at 9:47




                                            Sure, 'she' is an option too :)
                                            – Ali Ersöz
                                            Jan 12 '09 at 9:47










                                            up vote
                                            0
                                            down vote













                                            Explicitly set properties for anonymous types. Try This:



                                            dcDataContext db = new dcDataContext();
                                            var results = from c in db.tblSexes
                                            select new { c.SexCode, c.SexName };
                                            results = results.AsEnumerable().Concat(new { new { SexCode = -1, SexName = "Please select your Gender"} });
                                            SelectList sliSex = new SelectList(results, "SexCode", "SexName");


                                            Edit: You have to point the exact types of you properties. I mean if it is int you have to point that it is. I guess SexCode is a 'long' and by default -1 is an 'int'. If you cast -1 to long(or the type of SexCode) the problem will be solved.



                                            Here is the exact solution if SexCode's type is long.



                                            dcDataContext db = new dcDataContext();
                                            var results = from c in db.tblSexes
                                            select new { c.SexCode, c.SexName };
                                            results = results.Concat(new { new { SexCode = -1L, SexName = "Please select your Gender"} });
                                            SelectList sliSex = new SelectList(results, "SexCode", "SexName");





                                            share|improve this answer























                                            • I really appreciate your help, but it still doesn't work, I got the error msg: The type arguments for method 'System.Linq.Enumerable.Concat<TSource>, System.Collections.Generic.IEnumerable<TSource>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
                                              – silent200
                                              Jan 12 '09 at 9:34










                                            • Your welcome :) But I think you forgot to give the property names. Try 'new { new { SexCode = -1, SexName = "Please select your Gender"} }' not 'new { new { -1, "Please select your Gender"} }'. The error mentions that!
                                              – Ali Ersöz
                                              Jan 12 '09 at 9:41










                                            • Tried this one, but still won't work :o( Error: The type arguments for method 'System.Linq.Enumerable.Concat<TSource>(System.Collections.Generic.IEnumerable<TSource>, System.Collections.Generic.IEnumerable<TSource>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
                                              – silent200
                                              Jan 12 '09 at 9:52










                                            • Can you post the code that you wrote to here?
                                              – Ali Ersöz
                                              Jan 12 '09 at 9:54










                                            • Hi, I just updated my code, pls see the "answer" I posted above.
                                              – silent200
                                              Jan 12 '09 at 10:05















                                            up vote
                                            0
                                            down vote













                                            Explicitly set properties for anonymous types. Try This:



                                            dcDataContext db = new dcDataContext();
                                            var results = from c in db.tblSexes
                                            select new { c.SexCode, c.SexName };
                                            results = results.AsEnumerable().Concat(new { new { SexCode = -1, SexName = "Please select your Gender"} });
                                            SelectList sliSex = new SelectList(results, "SexCode", "SexName");


                                            Edit: You have to point the exact types of you properties. I mean if it is int you have to point that it is. I guess SexCode is a 'long' and by default -1 is an 'int'. If you cast -1 to long(or the type of SexCode) the problem will be solved.



                                            Here is the exact solution if SexCode's type is long.



                                            dcDataContext db = new dcDataContext();
                                            var results = from c in db.tblSexes
                                            select new { c.SexCode, c.SexName };
                                            results = results.Concat(new { new { SexCode = -1L, SexName = "Please select your Gender"} });
                                            SelectList sliSex = new SelectList(results, "SexCode", "SexName");





                                            share|improve this answer























                                            • I really appreciate your help, but it still doesn't work, I got the error msg: The type arguments for method 'System.Linq.Enumerable.Concat<TSource>, System.Collections.Generic.IEnumerable<TSource>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
                                              – silent200
                                              Jan 12 '09 at 9:34










                                            • Your welcome :) But I think you forgot to give the property names. Try 'new { new { SexCode = -1, SexName = "Please select your Gender"} }' not 'new { new { -1, "Please select your Gender"} }'. The error mentions that!
                                              – Ali Ersöz
                                              Jan 12 '09 at 9:41










                                            • Tried this one, but still won't work :o( Error: The type arguments for method 'System.Linq.Enumerable.Concat<TSource>(System.Collections.Generic.IEnumerable<TSource>, System.Collections.Generic.IEnumerable<TSource>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
                                              – silent200
                                              Jan 12 '09 at 9:52










                                            • Can you post the code that you wrote to here?
                                              – Ali Ersöz
                                              Jan 12 '09 at 9:54










                                            • Hi, I just updated my code, pls see the "answer" I posted above.
                                              – silent200
                                              Jan 12 '09 at 10:05













                                            up vote
                                            0
                                            down vote










                                            up vote
                                            0
                                            down vote









                                            Explicitly set properties for anonymous types. Try This:



                                            dcDataContext db = new dcDataContext();
                                            var results = from c in db.tblSexes
                                            select new { c.SexCode, c.SexName };
                                            results = results.AsEnumerable().Concat(new { new { SexCode = -1, SexName = "Please select your Gender"} });
                                            SelectList sliSex = new SelectList(results, "SexCode", "SexName");


                                            Edit: You have to point the exact types of you properties. I mean if it is int you have to point that it is. I guess SexCode is a 'long' and by default -1 is an 'int'. If you cast -1 to long(or the type of SexCode) the problem will be solved.



                                            Here is the exact solution if SexCode's type is long.



                                            dcDataContext db = new dcDataContext();
                                            var results = from c in db.tblSexes
                                            select new { c.SexCode, c.SexName };
                                            results = results.Concat(new { new { SexCode = -1L, SexName = "Please select your Gender"} });
                                            SelectList sliSex = new SelectList(results, "SexCode", "SexName");





                                            share|improve this answer














                                            Explicitly set properties for anonymous types. Try This:



                                            dcDataContext db = new dcDataContext();
                                            var results = from c in db.tblSexes
                                            select new { c.SexCode, c.SexName };
                                            results = results.AsEnumerable().Concat(new { new { SexCode = -1, SexName = "Please select your Gender"} });
                                            SelectList sliSex = new SelectList(results, "SexCode", "SexName");


                                            Edit: You have to point the exact types of you properties. I mean if it is int you have to point that it is. I guess SexCode is a 'long' and by default -1 is an 'int'. If you cast -1 to long(or the type of SexCode) the problem will be solved.



                                            Here is the exact solution if SexCode's type is long.



                                            dcDataContext db = new dcDataContext();
                                            var results = from c in db.tblSexes
                                            select new { c.SexCode, c.SexName };
                                            results = results.Concat(new { new { SexCode = -1L, SexName = "Please select your Gender"} });
                                            SelectList sliSex = new SelectList(results, "SexCode", "SexName");






                                            share|improve this answer














                                            share|improve this answer



                                            share|improve this answer








                                            edited Jan 12 '09 at 11:17

























                                            answered Jan 12 '09 at 9:24









                                            Ali Ersöz

                                            11.7k84561




                                            11.7k84561












                                            • I really appreciate your help, but it still doesn't work, I got the error msg: The type arguments for method 'System.Linq.Enumerable.Concat<TSource>, System.Collections.Generic.IEnumerable<TSource>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
                                              – silent200
                                              Jan 12 '09 at 9:34










                                            • Your welcome :) But I think you forgot to give the property names. Try 'new { new { SexCode = -1, SexName = "Please select your Gender"} }' not 'new { new { -1, "Please select your Gender"} }'. The error mentions that!
                                              – Ali Ersöz
                                              Jan 12 '09 at 9:41










                                            • Tried this one, but still won't work :o( Error: The type arguments for method 'System.Linq.Enumerable.Concat<TSource>(System.Collections.Generic.IEnumerable<TSource>, System.Collections.Generic.IEnumerable<TSource>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
                                              – silent200
                                              Jan 12 '09 at 9:52










                                            • Can you post the code that you wrote to here?
                                              – Ali Ersöz
                                              Jan 12 '09 at 9:54










                                            • Hi, I just updated my code, pls see the "answer" I posted above.
                                              – silent200
                                              Jan 12 '09 at 10:05


















                                            • I really appreciate your help, but it still doesn't work, I got the error msg: The type arguments for method 'System.Linq.Enumerable.Concat<TSource>, System.Collections.Generic.IEnumerable<TSource>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
                                              – silent200
                                              Jan 12 '09 at 9:34










                                            • Your welcome :) But I think you forgot to give the property names. Try 'new { new { SexCode = -1, SexName = "Please select your Gender"} }' not 'new { new { -1, "Please select your Gender"} }'. The error mentions that!
                                              – Ali Ersöz
                                              Jan 12 '09 at 9:41










                                            • Tried this one, but still won't work :o( Error: The type arguments for method 'System.Linq.Enumerable.Concat<TSource>(System.Collections.Generic.IEnumerable<TSource>, System.Collections.Generic.IEnumerable<TSource>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
                                              – silent200
                                              Jan 12 '09 at 9:52










                                            • Can you post the code that you wrote to here?
                                              – Ali Ersöz
                                              Jan 12 '09 at 9:54










                                            • Hi, I just updated my code, pls see the "answer" I posted above.
                                              – silent200
                                              Jan 12 '09 at 10:05
















                                            I really appreciate your help, but it still doesn't work, I got the error msg: The type arguments for method 'System.Linq.Enumerable.Concat<TSource>, System.Collections.Generic.IEnumerable<TSource>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
                                            – silent200
                                            Jan 12 '09 at 9:34




                                            I really appreciate your help, but it still doesn't work, I got the error msg: The type arguments for method 'System.Linq.Enumerable.Concat<TSource>, System.Collections.Generic.IEnumerable<TSource>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
                                            – silent200
                                            Jan 12 '09 at 9:34












                                            Your welcome :) But I think you forgot to give the property names. Try 'new { new { SexCode = -1, SexName = "Please select your Gender"} }' not 'new { new { -1, "Please select your Gender"} }'. The error mentions that!
                                            – Ali Ersöz
                                            Jan 12 '09 at 9:41




                                            Your welcome :) But I think you forgot to give the property names. Try 'new { new { SexCode = -1, SexName = "Please select your Gender"} }' not 'new { new { -1, "Please select your Gender"} }'. The error mentions that!
                                            – Ali Ersöz
                                            Jan 12 '09 at 9:41












                                            Tried this one, but still won't work :o( Error: The type arguments for method 'System.Linq.Enumerable.Concat<TSource>(System.Collections.Generic.IEnumerable<TSource>, System.Collections.Generic.IEnumerable<TSource>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
                                            – silent200
                                            Jan 12 '09 at 9:52




                                            Tried this one, but still won't work :o( Error: The type arguments for method 'System.Linq.Enumerable.Concat<TSource>(System.Collections.Generic.IEnumerable<TSource>, System.Collections.Generic.IEnumerable<TSource>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
                                            – silent200
                                            Jan 12 '09 at 9:52












                                            Can you post the code that you wrote to here?
                                            – Ali Ersöz
                                            Jan 12 '09 at 9:54




                                            Can you post the code that you wrote to here?
                                            – Ali Ersöz
                                            Jan 12 '09 at 9:54












                                            Hi, I just updated my code, pls see the "answer" I posted above.
                                            – silent200
                                            Jan 12 '09 at 10:05




                                            Hi, I just updated my code, pls see the "answer" I posted above.
                                            – silent200
                                            Jan 12 '09 at 10:05










                                            up vote
                                            0
                                            down vote













                                            You can use union



                                            IQueryable<int> foo = new SomeQueryable<int>();
                                            IQueryable<int> foo2 = new SomeQueryable<int>();
                                            foo = foo.Union(foo2);





                                            share|improve this answer










                                            New contributor




                                            Nurlan T is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                            Check out our Code of Conduct.






















                                              up vote
                                              0
                                              down vote













                                              You can use union



                                              IQueryable<int> foo = new SomeQueryable<int>();
                                              IQueryable<int> foo2 = new SomeQueryable<int>();
                                              foo = foo.Union(foo2);





                                              share|improve this answer










                                              New contributor




                                              Nurlan T is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                              Check out our Code of Conduct.




















                                                up vote
                                                0
                                                down vote










                                                up vote
                                                0
                                                down vote









                                                You can use union



                                                IQueryable<int> foo = new SomeQueryable<int>();
                                                IQueryable<int> foo2 = new SomeQueryable<int>();
                                                foo = foo.Union(foo2);





                                                share|improve this answer










                                                New contributor




                                                Nurlan T is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                Check out our Code of Conduct.









                                                You can use union



                                                IQueryable<int> foo = new SomeQueryable<int>();
                                                IQueryable<int> foo2 = new SomeQueryable<int>();
                                                foo = foo.Union(foo2);






                                                share|improve this answer










                                                New contributor




                                                Nurlan T is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                Check out our Code of Conduct.









                                                share|improve this answer



                                                share|improve this answer








                                                edited Nov 18 at 14:08









                                                quant

                                                1,53911526




                                                1,53911526






                                                New contributor




                                                Nurlan T is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                Check out our Code of Conduct.









                                                answered Nov 18 at 8:40









                                                Nurlan T

                                                11




                                                11




                                                New contributor




                                                Nurlan T is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                Check out our Code of Conduct.





                                                New contributor





                                                Nurlan T is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                Check out our Code of Conduct.






                                                Nurlan T is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                Check out our Code of Conduct.






























                                                     

                                                    draft saved


                                                    draft discarded



















































                                                     


                                                    draft saved


                                                    draft discarded














                                                    StackExchange.ready(
                                                    function () {
                                                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f434737%2fhow-do-i-add-a-new-record-to-an-iqueryable-variable%23new-answer', 'question_page');
                                                    }
                                                    );

                                                    Post as a guest















                                                    Required, but never shown





















































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown

































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown







                                                    Popular posts from this blog

                                                    Costa Masnaga

                                                    Fotorealismo

                                                    Sidney Franklin