Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to hand over my Object-Types in a correct way?
    primarykey
    data
    text
    <p>in the following method, I try to select specific IDs from one type of object. All above works, but the last part, where i hand the objects from query to a list of the specific object Type (T) makes problems, also the following methodes do not accept my input. I could imagine, on runtime this should all work fine, but visual-studio does not accept it.</p> <pre><code> private static Guid[] SelectiveQuery&lt;T&gt;(Guid[] ga, T input, string a) { List&lt;T&gt; li = new List&lt;T&gt;(); foreach (Guid g in ga) { var query = from produkt in Entity.ProduktCollection.produktCollection let p = produkt as Entity.Produkt from version in p.version let v = version as Entity.Version from customer in v.customerCollection let c = customer as Entity.Customer from fehler in v.fehlerCollection let f = fehler as Entity.Fehler select new {p, v, c, f}; switch (a) { case "produkt": query = query.Where(x =&gt; x.p.id == g); break; case "version": query = query.Where(x =&gt; x.v.id == g); break; case "customer": query = query.Where(x =&gt; x.c.id == g); break; case "fehler": query = query.Where(x =&gt; x.f.id == g); break; case "kategorie": query = query.Where(x =&gt; x.f.kategorie.id == g); break; } query = query.Where(x =&gt; x.GetType() == typeof(T)); li.AddRange(query); //contains error ("System.Collections.Generic.IEnumerable&lt;AnonymousType#1&gt;" can't be converted to "System.Collections.Generic.IEnumerable&lt;T&gt;" } // Reduce() removes duplicates in li and returns the list li = Reduce(li, i =&gt; i.id); //contains error (T doesn't contain a definition for id) // Guids() makes a list of all IDs inside li and returns this List&lt;Guid&gt; return Guids(li, i =&gt; i.id); //contains error (T doesn't contain a definition for id) } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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. 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