title: A local or parameter named cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter
body: <p>I have the following linq code</p>
  
  <pre><code>var advertisements = _applicationContext.Advertisings.ToList();
  
  var stepsData = advertisements.Select(a =&gt; new[]
  {
      new
      {
          number = a.Number,
          text = a.Text,
          image = a.Image,
          type = a.Type,
          data = (a) =&gt;
          {
              if (string.IsNullOrEmpty(a.Link) || string.IsNullOrEmpty(a.Deeplink))
              {
                  return null;
              }
  
              return new
              {
                  link = a.Link,
                  deeplink = a.Deeplink
              };
          }
      }
  });
  </code></pre>
  
  <p>See on the <code>data</code> property. A value of this property depends on values <code>Link</code> and <code>DeepLink</code> of item <code>a</code>. The <code>a</code> is an instance of the following model: </p>
  
  <pre><code>public class Advertising
  {
      [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
      public int Id { get; set; }
  
      public int Number { get; set; }
  
      public string Text { get; set; }
  
      public string Image { get; set; }
  
      public string Type { get; set; }
  
      public bool Show { get; set; }
  
      public string Link { get; set; }
  
      public string Deeplink { get; set; }
  
      public DateTime CreatedAt { get; set; }
  
      public DateTime UpdatedAt { get; set; }
  
      public Advertising()
      {
          CreatedAt = DateTime.UtcNow;
          UpdatedAt = DateTime.UtcNow;
      }
  }
  </code></pre>
  
  <p>All is good, but I see a notification from IDE 
  <code>A local or parameter named 'a' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter</code></p>
  
  <p>How to use lambda in this case? I need to pass into the lambda variable <code>a</code>. Without params, it shows me the following error
  <code>Cannot assign 'lambda expression' to anonymous type property</code></p>
  
  <h2>Update</h2>
  
  <p>Lambda without params gives me the following result</p>
  
  <p><a href="https://i.stack.imgur.com/XPaSt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XPaSt.png" alt="enter image description here"></a></p>
  
  <p>Error text:
  <code>Cannot assign 'lambda expression' to anonymous type property</code></p>