title: How to find all id and autopaste as parameter using linq?
body: <p>I have 2 projects. One of them aspnet core webapi and second one is console application which is consuming api. </p>
  
  <p>Api method looks like:</p>
  
  <pre><code>        [HttpPost]
          public async Task&lt;IActionResult&gt; CreateBillingInfo(BillingSummary 
          billingSummaryCreateDto)
          {
              var role = User.FindFirst(ClaimTypes.Role).Value;
              if (role != "admin")
              {
                  return BadRequest("Available only for admin");
              }        
  
              ... other properties
              billingSummaryCreateDto.Price = icu * roc.Price;
              billingSummaryCreateDto.Project =
                  await _context.Projects.FirstOrDefaultAsync(x =&gt; x.Id == 
              billingSummaryCreateDto.ProjectId);
  
              await _context.BillingSummaries.AddAsync(billingSummaryCreateDto);
              await _context.SaveChangesAsync();
  
              return StatusCode(201);
          }
  </code></pre>
  
  <p>Console application which consuming api:</p>
  
  <pre><code>    public static async Task CreateBillingSummary(int projectId)
      {
          var json = JsonConvert.SerializeObject(new {projectId});
          var data = new StringContent(json, Encoding.UTF8, "application/json");
  
          using var client = new HttpClient();
          client.DefaultRequestHeaders.Authorization =
              new AuthenticationHeaderValue("Bearer", await Token.GetToken());
  
          var loginResponse = await client.PostAsync(LibvirtUrls.createBillingSummaryUrl, 
          data);
  
          WriteLine("Response Status Code: " + (int) loginResponse.StatusCode);
          string result = loginResponse.Content.ReadAsStringAsync().Result; 
          WriteLine(result);
      }
  </code></pre>
  
  <p>Program.cs main method looks like:   </p>
  
  <pre><code>    static async Task Main(string[] args)
      {
          if (Environment.GetEnvironmentVariable("TAIKUN_USER") == null ||
              Environment.GetEnvironmentVariable("TAIKUN_PASSWORD") == null ||
              Environment.GetEnvironmentVariable("TAIKUN_URL") == null)
          {
              Console.WriteLine("Please specify all credentials");
              Environment.Exit(0);
          }
  
          Timer timer = new Timer(1000); // show time every second
          timer.Elapsed += Timer_Elapsed;
          timer.Start();
          while (true)
          {
              Thread.Sleep(1000); // after 1 second begin
              await PollerRequests.CreateBillingSummary(60); // auto id
              await PollerRequests.CreateBillingSummary(59); // auto id
              Thread.Sleep(3600000); // 1hour wait again requests
          }
  
      }
  </code></pre>
  
  <p>Is it possible find all id and paste it automatically instead of 59 and 60? Ids from projects table. _context.Projects</p>
  
  <p>Tried also approach using method which returns ids</p>
  
  <pre><code>    public static async Task&lt;IEnumerable&lt;int&gt;&gt; GetProjectIds2()
      {
          var json = await 
         Helpers.Transformer(LibvirtUrls.projectsUrl);
          List&lt;ProjectListDto&gt; vmList = 
          JsonConvert.DeserializeObject&lt;List&lt;ProjectListDto&gt;&gt;(json);
  
          return vmList.Select(x =&gt; x.Id).AsEnumerable(); // tried 
          ToList() as well
      }
  </code></pre>
  
  <p>and in main method used:</p>
  
  <pre><code>foreach (var i in await PollerRequests.GetProjectIds2())
                       new List&lt;int&gt; { i }
                           .ForEach(async c =&gt; await 
               PollerRequests.CreateBillingSummary(c));
  </code></pre>
  
  <p>for first 3 ids it worked but does not get other ones,
  tested with console writeline method returns all ids </p>