Collections returning












0















I am having difficulty getting two records out of a function when using
collection. I don't know what I am doing wrong, thank you in advance for any
help.



Service calling function...



Announcements announcements = new Announcements(ID, moduleID, _config, _logger);

return announcements; // this does not contain anything although Announcements load functions has two record


namespace Api.Collection
{
public class Announcements : List<Announcement>
{
IConfiguration _config;
ILoggerManager _logger;

private string _uspGetAnnouncement = "storedproced_GetAnnouncemnt";

public List<Announcement> announcements = new List<Announcement>();
public Announcements()
{

}
public Announcements(int employeeID, int moduleID, IConfiguration config, ILoggerManager logger)
{
_config = config;
_logger = logger;

if (employeeID > 0 && moduleID > 0)
{
Load(employeeID, moduleID);
}
}

public virtual void Load(int employeeID, int moduleID)
{
List<SqlParameter> lParam = new List<SqlParameter>();

Util.DataUtil dataUtil = new Util.DataUtil(_config);
SqlParameter param;

if (employeeID > 0 && moduleID > 0)
{
param = new SqlParameter("@employeeID", employeeID);
lParam.Add(param);

param = new SqlParameter("@moduleID", moduleID);
lParam.Add(param);
}

DataTable dt = Util.GetDataTable(_uspGetAnnouncement, lParam.ToArray());

if (dt.Rows.Count > 0)
{
foreach (DataRow dr in dt.Rows)
{
announcements.Add(new Announcement(dr, dt.Rows.Count, _config, _logger));
}
}
return announcements; *** this has 2 records
}
}
}









share|improve this question

























  • you call a function with the keyword void (which means no return value), and then try to call a return function ? That do not work.

    – Glowhollow
    Jan 18 at 16:11






  • 1





    Announcements : List<Announcement> don't do this. See this question for an explanation of why

    – A Friend
    Jan 18 at 16:15
















0















I am having difficulty getting two records out of a function when using
collection. I don't know what I am doing wrong, thank you in advance for any
help.



Service calling function...



Announcements announcements = new Announcements(ID, moduleID, _config, _logger);

return announcements; // this does not contain anything although Announcements load functions has two record


namespace Api.Collection
{
public class Announcements : List<Announcement>
{
IConfiguration _config;
ILoggerManager _logger;

private string _uspGetAnnouncement = "storedproced_GetAnnouncemnt";

public List<Announcement> announcements = new List<Announcement>();
public Announcements()
{

}
public Announcements(int employeeID, int moduleID, IConfiguration config, ILoggerManager logger)
{
_config = config;
_logger = logger;

if (employeeID > 0 && moduleID > 0)
{
Load(employeeID, moduleID);
}
}

public virtual void Load(int employeeID, int moduleID)
{
List<SqlParameter> lParam = new List<SqlParameter>();

Util.DataUtil dataUtil = new Util.DataUtil(_config);
SqlParameter param;

if (employeeID > 0 && moduleID > 0)
{
param = new SqlParameter("@employeeID", employeeID);
lParam.Add(param);

param = new SqlParameter("@moduleID", moduleID);
lParam.Add(param);
}

DataTable dt = Util.GetDataTable(_uspGetAnnouncement, lParam.ToArray());

if (dt.Rows.Count > 0)
{
foreach (DataRow dr in dt.Rows)
{
announcements.Add(new Announcement(dr, dt.Rows.Count, _config, _logger));
}
}
return announcements; *** this has 2 records
}
}
}









share|improve this question

























  • you call a function with the keyword void (which means no return value), and then try to call a return function ? That do not work.

    – Glowhollow
    Jan 18 at 16:11






  • 1





    Announcements : List<Announcement> don't do this. See this question for an explanation of why

    – A Friend
    Jan 18 at 16:15














0












0








0








I am having difficulty getting two records out of a function when using
collection. I don't know what I am doing wrong, thank you in advance for any
help.



Service calling function...



Announcements announcements = new Announcements(ID, moduleID, _config, _logger);

return announcements; // this does not contain anything although Announcements load functions has two record


namespace Api.Collection
{
public class Announcements : List<Announcement>
{
IConfiguration _config;
ILoggerManager _logger;

private string _uspGetAnnouncement = "storedproced_GetAnnouncemnt";

public List<Announcement> announcements = new List<Announcement>();
public Announcements()
{

}
public Announcements(int employeeID, int moduleID, IConfiguration config, ILoggerManager logger)
{
_config = config;
_logger = logger;

if (employeeID > 0 && moduleID > 0)
{
Load(employeeID, moduleID);
}
}

public virtual void Load(int employeeID, int moduleID)
{
List<SqlParameter> lParam = new List<SqlParameter>();

Util.DataUtil dataUtil = new Util.DataUtil(_config);
SqlParameter param;

if (employeeID > 0 && moduleID > 0)
{
param = new SqlParameter("@employeeID", employeeID);
lParam.Add(param);

param = new SqlParameter("@moduleID", moduleID);
lParam.Add(param);
}

DataTable dt = Util.GetDataTable(_uspGetAnnouncement, lParam.ToArray());

if (dt.Rows.Count > 0)
{
foreach (DataRow dr in dt.Rows)
{
announcements.Add(new Announcement(dr, dt.Rows.Count, _config, _logger));
}
}
return announcements; *** this has 2 records
}
}
}









share|improve this question
















I am having difficulty getting two records out of a function when using
collection. I don't know what I am doing wrong, thank you in advance for any
help.



Service calling function...



Announcements announcements = new Announcements(ID, moduleID, _config, _logger);

return announcements; // this does not contain anything although Announcements load functions has two record


namespace Api.Collection
{
public class Announcements : List<Announcement>
{
IConfiguration _config;
ILoggerManager _logger;

private string _uspGetAnnouncement = "storedproced_GetAnnouncemnt";

public List<Announcement> announcements = new List<Announcement>();
public Announcements()
{

}
public Announcements(int employeeID, int moduleID, IConfiguration config, ILoggerManager logger)
{
_config = config;
_logger = logger;

if (employeeID > 0 && moduleID > 0)
{
Load(employeeID, moduleID);
}
}

public virtual void Load(int employeeID, int moduleID)
{
List<SqlParameter> lParam = new List<SqlParameter>();

Util.DataUtil dataUtil = new Util.DataUtil(_config);
SqlParameter param;

if (employeeID > 0 && moduleID > 0)
{
param = new SqlParameter("@employeeID", employeeID);
lParam.Add(param);

param = new SqlParameter("@moduleID", moduleID);
lParam.Add(param);
}

DataTable dt = Util.GetDataTable(_uspGetAnnouncement, lParam.ToArray());

if (dt.Rows.Count > 0)
{
foreach (DataRow dr in dt.Rows)
{
announcements.Add(new Announcement(dr, dt.Rows.Count, _config, _logger));
}
}
return announcements; *** this has 2 records
}
}
}






c# .net rest api






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 18 at 16:12









User

54.6k676123




54.6k676123










asked Jan 18 at 16:09









Rocio BordaRocio Borda

92




92













  • you call a function with the keyword void (which means no return value), and then try to call a return function ? That do not work.

    – Glowhollow
    Jan 18 at 16:11






  • 1





    Announcements : List<Announcement> don't do this. See this question for an explanation of why

    – A Friend
    Jan 18 at 16:15



















  • you call a function with the keyword void (which means no return value), and then try to call a return function ? That do not work.

    – Glowhollow
    Jan 18 at 16:11






  • 1





    Announcements : List<Announcement> don't do this. See this question for an explanation of why

    – A Friend
    Jan 18 at 16:15

















you call a function with the keyword void (which means no return value), and then try to call a return function ? That do not work.

– Glowhollow
Jan 18 at 16:11





you call a function with the keyword void (which means no return value), and then try to call a return function ? That do not work.

– Glowhollow
Jan 18 at 16:11




1




1





Announcements : List<Announcement> don't do this. See this question for an explanation of why

– A Friend
Jan 18 at 16:15





Announcements : List<Announcement> don't do this. See this question for an explanation of why

– A Friend
Jan 18 at 16:15












2 Answers
2






active

oldest

votes


















0














A Friends comment could be right, but I don't know your use case so maybe it is valid.
As sort of stated in other comments/answers the Load method doesn't return anything so your line



return announcements;


does nothing.
Your are actually adding the items to the internal list you have.
So I'm guessing with your current code, this would work to show you your two items in your service code.



Announcements announcements = new Announcements(ID, moduleID, _config, _logger);
return announcements.announcements;


Obviously that looks confusing and isn't what you wanted. Since you are inheriting from List what you want to do is add the items to itself in the Load function. So I believe the following code would work. The key being to use just Add instead of announcements.Add



namespace Api.Collection
{
public class Announcements : List<Announcement>
{
IConfiguration _config;
ILoggerManager _logger;

private string _uspGetAnnouncement = "storedproced_GetAnnouncemnt";

public Announcements()
{

}
public Announcements(int employeeID, int moduleID, IConfiguration config, ILoggerManager logger)
{
_config = config;
_logger = logger;

if (employeeID > 0 && moduleID > 0)
{
Load(employeeID, moduleID);
}
}

public virtual void Load(int employeeID, int moduleID)
{
List<SqlParameter> lParam = new List<SqlParameter>();

Util.DataUtil dataUtil = new Util.DataUtil(_config);
SqlParameter param;

if (employeeID > 0 && moduleID > 0)
{
param = new SqlParameter("@employeeID", employeeID);
lParam.Add(param);

param = new SqlParameter("@moduleID", moduleID);
lParam.Add(param);
}

DataTable dt = Util.GetDataTable(_uspGetAnnouncement, lParam.ToArray());

if (dt.Rows.Count > 0)
{
foreach (DataRow dr in dt.Rows)
{
Add(new Announcement(dr, dt.Rows.Count, _config, _logger));
}
}
}
}
}





share|improve this answer








New contributor




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




























    -1














    Not sure if that works.



        namespace Api.Collection
    {
    public class Announcements : List<Announcement>
    {
    IConfiguration _config;
    ILoggerManager _logger;

    private string _uspGetAnnouncement = "storedproced_GetAnnouncemnt";

    public List<Announcement> announcements = new List<Announcement>();
    public Announcements()
    {

    }
    public Announcements(int employeeID, int moduleID, IConfiguration config, ILoggerManager logger)
    {
    _config = config;
    _logger = logger;

    if (employeeID > 0 && moduleID > 0)
    {
    var value = Load(employeeID, moduleID);
    }
    }

    public virtual List<Announcement> Load(int employeeID, int moduleID)
    {
    List<SqlParameter> lParam = new List<SqlParameter>();

    Util.DataUtil dataUtil = new Util.DataUtil(_config);
    SqlParameter param;

    if (employeeID > 0 && moduleID > 0)
    {
    param = new SqlParameter("@employeeID", employeeID);
    lParam.Add(param);

    param = new SqlParameter("@moduleID", moduleID);
    lParam.Add(param);
    }

    DataTable dt = Util.GetDataTable(_uspGetAnnouncement, lParam.ToArray());

    if (dt.Rows.Count > 0)
    {
    foreach (DataRow dr in dt.Rows)
    {
    announcements.Add(new Announcement(dr, dt.Rows.Count, _config, _logger));
    }
    }
    return announcements; *** this has 2 records
    }
    }
    }


    i hope that clarify something....



    greetings






    share|improve this answer























      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',
      autoActivateHeartbeat: false,
      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%2f54257607%2fcollections-returning%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      A Friends comment could be right, but I don't know your use case so maybe it is valid.
      As sort of stated in other comments/answers the Load method doesn't return anything so your line



      return announcements;


      does nothing.
      Your are actually adding the items to the internal list you have.
      So I'm guessing with your current code, this would work to show you your two items in your service code.



      Announcements announcements = new Announcements(ID, moduleID, _config, _logger);
      return announcements.announcements;


      Obviously that looks confusing and isn't what you wanted. Since you are inheriting from List what you want to do is add the items to itself in the Load function. So I believe the following code would work. The key being to use just Add instead of announcements.Add



      namespace Api.Collection
      {
      public class Announcements : List<Announcement>
      {
      IConfiguration _config;
      ILoggerManager _logger;

      private string _uspGetAnnouncement = "storedproced_GetAnnouncemnt";

      public Announcements()
      {

      }
      public Announcements(int employeeID, int moduleID, IConfiguration config, ILoggerManager logger)
      {
      _config = config;
      _logger = logger;

      if (employeeID > 0 && moduleID > 0)
      {
      Load(employeeID, moduleID);
      }
      }

      public virtual void Load(int employeeID, int moduleID)
      {
      List<SqlParameter> lParam = new List<SqlParameter>();

      Util.DataUtil dataUtil = new Util.DataUtil(_config);
      SqlParameter param;

      if (employeeID > 0 && moduleID > 0)
      {
      param = new SqlParameter("@employeeID", employeeID);
      lParam.Add(param);

      param = new SqlParameter("@moduleID", moduleID);
      lParam.Add(param);
      }

      DataTable dt = Util.GetDataTable(_uspGetAnnouncement, lParam.ToArray());

      if (dt.Rows.Count > 0)
      {
      foreach (DataRow dr in dt.Rows)
      {
      Add(new Announcement(dr, dt.Rows.Count, _config, _logger));
      }
      }
      }
      }
      }





      share|improve this answer








      New contributor




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

























        0














        A Friends comment could be right, but I don't know your use case so maybe it is valid.
        As sort of stated in other comments/answers the Load method doesn't return anything so your line



        return announcements;


        does nothing.
        Your are actually adding the items to the internal list you have.
        So I'm guessing with your current code, this would work to show you your two items in your service code.



        Announcements announcements = new Announcements(ID, moduleID, _config, _logger);
        return announcements.announcements;


        Obviously that looks confusing and isn't what you wanted. Since you are inheriting from List what you want to do is add the items to itself in the Load function. So I believe the following code would work. The key being to use just Add instead of announcements.Add



        namespace Api.Collection
        {
        public class Announcements : List<Announcement>
        {
        IConfiguration _config;
        ILoggerManager _logger;

        private string _uspGetAnnouncement = "storedproced_GetAnnouncemnt";

        public Announcements()
        {

        }
        public Announcements(int employeeID, int moduleID, IConfiguration config, ILoggerManager logger)
        {
        _config = config;
        _logger = logger;

        if (employeeID > 0 && moduleID > 0)
        {
        Load(employeeID, moduleID);
        }
        }

        public virtual void Load(int employeeID, int moduleID)
        {
        List<SqlParameter> lParam = new List<SqlParameter>();

        Util.DataUtil dataUtil = new Util.DataUtil(_config);
        SqlParameter param;

        if (employeeID > 0 && moduleID > 0)
        {
        param = new SqlParameter("@employeeID", employeeID);
        lParam.Add(param);

        param = new SqlParameter("@moduleID", moduleID);
        lParam.Add(param);
        }

        DataTable dt = Util.GetDataTable(_uspGetAnnouncement, lParam.ToArray());

        if (dt.Rows.Count > 0)
        {
        foreach (DataRow dr in dt.Rows)
        {
        Add(new Announcement(dr, dt.Rows.Count, _config, _logger));
        }
        }
        }
        }
        }





        share|improve this answer








        New contributor




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























          0












          0








          0







          A Friends comment could be right, but I don't know your use case so maybe it is valid.
          As sort of stated in other comments/answers the Load method doesn't return anything so your line



          return announcements;


          does nothing.
          Your are actually adding the items to the internal list you have.
          So I'm guessing with your current code, this would work to show you your two items in your service code.



          Announcements announcements = new Announcements(ID, moduleID, _config, _logger);
          return announcements.announcements;


          Obviously that looks confusing and isn't what you wanted. Since you are inheriting from List what you want to do is add the items to itself in the Load function. So I believe the following code would work. The key being to use just Add instead of announcements.Add



          namespace Api.Collection
          {
          public class Announcements : List<Announcement>
          {
          IConfiguration _config;
          ILoggerManager _logger;

          private string _uspGetAnnouncement = "storedproced_GetAnnouncemnt";

          public Announcements()
          {

          }
          public Announcements(int employeeID, int moduleID, IConfiguration config, ILoggerManager logger)
          {
          _config = config;
          _logger = logger;

          if (employeeID > 0 && moduleID > 0)
          {
          Load(employeeID, moduleID);
          }
          }

          public virtual void Load(int employeeID, int moduleID)
          {
          List<SqlParameter> lParam = new List<SqlParameter>();

          Util.DataUtil dataUtil = new Util.DataUtil(_config);
          SqlParameter param;

          if (employeeID > 0 && moduleID > 0)
          {
          param = new SqlParameter("@employeeID", employeeID);
          lParam.Add(param);

          param = new SqlParameter("@moduleID", moduleID);
          lParam.Add(param);
          }

          DataTable dt = Util.GetDataTable(_uspGetAnnouncement, lParam.ToArray());

          if (dt.Rows.Count > 0)
          {
          foreach (DataRow dr in dt.Rows)
          {
          Add(new Announcement(dr, dt.Rows.Count, _config, _logger));
          }
          }
          }
          }
          }





          share|improve this answer








          New contributor




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










          A Friends comment could be right, but I don't know your use case so maybe it is valid.
          As sort of stated in other comments/answers the Load method doesn't return anything so your line



          return announcements;


          does nothing.
          Your are actually adding the items to the internal list you have.
          So I'm guessing with your current code, this would work to show you your two items in your service code.



          Announcements announcements = new Announcements(ID, moduleID, _config, _logger);
          return announcements.announcements;


          Obviously that looks confusing and isn't what you wanted. Since you are inheriting from List what you want to do is add the items to itself in the Load function. So I believe the following code would work. The key being to use just Add instead of announcements.Add



          namespace Api.Collection
          {
          public class Announcements : List<Announcement>
          {
          IConfiguration _config;
          ILoggerManager _logger;

          private string _uspGetAnnouncement = "storedproced_GetAnnouncemnt";

          public Announcements()
          {

          }
          public Announcements(int employeeID, int moduleID, IConfiguration config, ILoggerManager logger)
          {
          _config = config;
          _logger = logger;

          if (employeeID > 0 && moduleID > 0)
          {
          Load(employeeID, moduleID);
          }
          }

          public virtual void Load(int employeeID, int moduleID)
          {
          List<SqlParameter> lParam = new List<SqlParameter>();

          Util.DataUtil dataUtil = new Util.DataUtil(_config);
          SqlParameter param;

          if (employeeID > 0 && moduleID > 0)
          {
          param = new SqlParameter("@employeeID", employeeID);
          lParam.Add(param);

          param = new SqlParameter("@moduleID", moduleID);
          lParam.Add(param);
          }

          DataTable dt = Util.GetDataTable(_uspGetAnnouncement, lParam.ToArray());

          if (dt.Rows.Count > 0)
          {
          foreach (DataRow dr in dt.Rows)
          {
          Add(new Announcement(dr, dt.Rows.Count, _config, _logger));
          }
          }
          }
          }
          }






          share|improve this answer








          New contributor




          Dan Sponseller 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






          New contributor




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









          answered Jan 18 at 18:04









          Dan SponsellerDan Sponseller

          12




          12




          New contributor




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





          New contributor





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






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

























              -1














              Not sure if that works.



                  namespace Api.Collection
              {
              public class Announcements : List<Announcement>
              {
              IConfiguration _config;
              ILoggerManager _logger;

              private string _uspGetAnnouncement = "storedproced_GetAnnouncemnt";

              public List<Announcement> announcements = new List<Announcement>();
              public Announcements()
              {

              }
              public Announcements(int employeeID, int moduleID, IConfiguration config, ILoggerManager logger)
              {
              _config = config;
              _logger = logger;

              if (employeeID > 0 && moduleID > 0)
              {
              var value = Load(employeeID, moduleID);
              }
              }

              public virtual List<Announcement> Load(int employeeID, int moduleID)
              {
              List<SqlParameter> lParam = new List<SqlParameter>();

              Util.DataUtil dataUtil = new Util.DataUtil(_config);
              SqlParameter param;

              if (employeeID > 0 && moduleID > 0)
              {
              param = new SqlParameter("@employeeID", employeeID);
              lParam.Add(param);

              param = new SqlParameter("@moduleID", moduleID);
              lParam.Add(param);
              }

              DataTable dt = Util.GetDataTable(_uspGetAnnouncement, lParam.ToArray());

              if (dt.Rows.Count > 0)
              {
              foreach (DataRow dr in dt.Rows)
              {
              announcements.Add(new Announcement(dr, dt.Rows.Count, _config, _logger));
              }
              }
              return announcements; *** this has 2 records
              }
              }
              }


              i hope that clarify something....



              greetings






              share|improve this answer




























                -1














                Not sure if that works.



                    namespace Api.Collection
                {
                public class Announcements : List<Announcement>
                {
                IConfiguration _config;
                ILoggerManager _logger;

                private string _uspGetAnnouncement = "storedproced_GetAnnouncemnt";

                public List<Announcement> announcements = new List<Announcement>();
                public Announcements()
                {

                }
                public Announcements(int employeeID, int moduleID, IConfiguration config, ILoggerManager logger)
                {
                _config = config;
                _logger = logger;

                if (employeeID > 0 && moduleID > 0)
                {
                var value = Load(employeeID, moduleID);
                }
                }

                public virtual List<Announcement> Load(int employeeID, int moduleID)
                {
                List<SqlParameter> lParam = new List<SqlParameter>();

                Util.DataUtil dataUtil = new Util.DataUtil(_config);
                SqlParameter param;

                if (employeeID > 0 && moduleID > 0)
                {
                param = new SqlParameter("@employeeID", employeeID);
                lParam.Add(param);

                param = new SqlParameter("@moduleID", moduleID);
                lParam.Add(param);
                }

                DataTable dt = Util.GetDataTable(_uspGetAnnouncement, lParam.ToArray());

                if (dt.Rows.Count > 0)
                {
                foreach (DataRow dr in dt.Rows)
                {
                announcements.Add(new Announcement(dr, dt.Rows.Count, _config, _logger));
                }
                }
                return announcements; *** this has 2 records
                }
                }
                }


                i hope that clarify something....



                greetings






                share|improve this answer


























                  -1












                  -1








                  -1







                  Not sure if that works.



                      namespace Api.Collection
                  {
                  public class Announcements : List<Announcement>
                  {
                  IConfiguration _config;
                  ILoggerManager _logger;

                  private string _uspGetAnnouncement = "storedproced_GetAnnouncemnt";

                  public List<Announcement> announcements = new List<Announcement>();
                  public Announcements()
                  {

                  }
                  public Announcements(int employeeID, int moduleID, IConfiguration config, ILoggerManager logger)
                  {
                  _config = config;
                  _logger = logger;

                  if (employeeID > 0 && moduleID > 0)
                  {
                  var value = Load(employeeID, moduleID);
                  }
                  }

                  public virtual List<Announcement> Load(int employeeID, int moduleID)
                  {
                  List<SqlParameter> lParam = new List<SqlParameter>();

                  Util.DataUtil dataUtil = new Util.DataUtil(_config);
                  SqlParameter param;

                  if (employeeID > 0 && moduleID > 0)
                  {
                  param = new SqlParameter("@employeeID", employeeID);
                  lParam.Add(param);

                  param = new SqlParameter("@moduleID", moduleID);
                  lParam.Add(param);
                  }

                  DataTable dt = Util.GetDataTable(_uspGetAnnouncement, lParam.ToArray());

                  if (dt.Rows.Count > 0)
                  {
                  foreach (DataRow dr in dt.Rows)
                  {
                  announcements.Add(new Announcement(dr, dt.Rows.Count, _config, _logger));
                  }
                  }
                  return announcements; *** this has 2 records
                  }
                  }
                  }


                  i hope that clarify something....



                  greetings






                  share|improve this answer













                  Not sure if that works.



                      namespace Api.Collection
                  {
                  public class Announcements : List<Announcement>
                  {
                  IConfiguration _config;
                  ILoggerManager _logger;

                  private string _uspGetAnnouncement = "storedproced_GetAnnouncemnt";

                  public List<Announcement> announcements = new List<Announcement>();
                  public Announcements()
                  {

                  }
                  public Announcements(int employeeID, int moduleID, IConfiguration config, ILoggerManager logger)
                  {
                  _config = config;
                  _logger = logger;

                  if (employeeID > 0 && moduleID > 0)
                  {
                  var value = Load(employeeID, moduleID);
                  }
                  }

                  public virtual List<Announcement> Load(int employeeID, int moduleID)
                  {
                  List<SqlParameter> lParam = new List<SqlParameter>();

                  Util.DataUtil dataUtil = new Util.DataUtil(_config);
                  SqlParameter param;

                  if (employeeID > 0 && moduleID > 0)
                  {
                  param = new SqlParameter("@employeeID", employeeID);
                  lParam.Add(param);

                  param = new SqlParameter("@moduleID", moduleID);
                  lParam.Add(param);
                  }

                  DataTable dt = Util.GetDataTable(_uspGetAnnouncement, lParam.ToArray());

                  if (dt.Rows.Count > 0)
                  {
                  foreach (DataRow dr in dt.Rows)
                  {
                  announcements.Add(new Announcement(dr, dt.Rows.Count, _config, _logger));
                  }
                  }
                  return announcements; *** this has 2 records
                  }
                  }
                  }


                  i hope that clarify something....



                  greetings







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 18 at 16:17









                  GlowhollowGlowhollow

                  579




                  579






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54257607%2fcollections-returning%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

                      Homophylophilia

                      Updating UILabel text programmatically using a function

                      Cloud Functions - OpenCV Videocapture Read method fails for larger files from cloud storage