Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You'll need to either use a normal type for the projection, or make the method you're passing it to generic as well (which will mean you can't do as much with it). What exactly are you trying to do? If you need to use the X and Y values from the method, you'll definitely need to create a normal type. (There are horribly hacky ways of avoiding it, but they're not a good idea.)</p> <p>Note: some other answers are currently talking about <code>IQueryable&lt;T&gt;</code>, but there's no indication that you're using anything more than LINQ to Objects, in which case it'll be an <code>IEnumerable&lt;T&gt;</code> instead - but the <code>T</code> is currently an anonymous type. That's the bit you'll need to work on if you want to use the individual values within each item. If you're <em>not</em> using LINQ to Objects, please clarify the question and I'll edit this answer.</p> <p>For example, taking your current query (which is slightly broken, as you can't use two projection initializers twice with the same name X). You'd create a new type, e.g. <code>MyPoint</code> </p> <pre><code>public sealed class MyPoint { private readonly int x; private readonly int y; public int X { get { return x; } } public int Y { get { return y; } } public MyPoint(int x, int y) { this.x = x; this.y = y; } } </code></pre> <p>Your query would then be:</p> <pre><code>var query = from p in pointList where p.X &lt; 100 select new MyPoint(p.X, p.Y); </code></pre> <p>You'd then write your method as:</p> <pre><code>public void SomeMethod(IEnumerable&lt;MyPoint&gt; points) { ... } </code></pre> <p>And call it as <code>SomeMethod(query);</code></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload