score:2
this code works for me, and its a direct copy of your code, minus the itemmovement and its interface, so perhaps something is wrong with that part?
public class testclient
{
public static void main(string[] args)
{
var p = new list<iitem>();
p.add(new item { name = "aaron" });
p.add(new item { name = "jeremy" });
var ims = p.toentitysetfrominterface<item, iitem>();
foreach (var itm in ims)
{
console.writeline(itm);
}
console.readkey(true);
}
}
public class item : iitem
{
public string name { get; set; }
public override string tostring()
{
return name;
}
}
public interface iitem
{
}
public static class extmethod
{
public static entityset<t> toentitysetfrominterface<t, u>(this ilist<u> source) where t : class, u
{
var es = new entityset<t>();
ienumerator<u> ie = source.getenumerator();
while (ie.movenext())
{
es.add((t)ie.current);
}
return es;
}
}
score:1
this part of the compiler error is the key: "no extension method 'toentitysetfrominterface' accepting a first argument of type 'system.collections.generic.list'".
your toentitysetfrominterface<t,u>
extension method is defined to accept an ilist<u>
but you're attempting to call it with a list<t>
rather than an ilist<t>
. the compliler isn't finding your extension method because the type doesn't match.
Source: stackoverflow.com
Related Query
- Extension method not found (not an assembly reference issue)
- LinqPad Linq Include() extension method is not found even after adding references
- 'IEnumerable<>' does not contain a definition for '' and no extension method '' accepting a first argument of type 'IEnumerable<>' could be found
- int' does not contain a definition for 'contains' and no extension method 'contains' accepting a first argument of type 'int' could be found
- Instantiate a class in MVC 5 gives error [class] does not contain a definition for [member] and no extension method [member] ... could be found
- Code equivalent to the 'let' keyword in chained LINQ extension method calls
- IQueryable<T> does not contain a definition for 'Include' and no extension method 'Include'
- Enumerable.Empty<T>().AsQueryable(); This method supports the LINQ to Entities infrastructure and is not intended to be used directly from your code
- System.Xml.Linq.XElement>' does not contain a definition for 'First' and no extension method 'First' accepting a first argument of
- IQueryable<T> Extension Method not working
- Add a LINQ or DBContext extension method to get an element if not exist then create with data in predicate (FirstOrCreate)
- Avoid extra loop and could not find implementation of query pattern for source type int Select not found
- LINQ to Entities Method Not Recognized - Extension Method Style
- Nhibernate linq. The where extension method does not add the where clause to the SQL command, why?
- Ravendb Session.Query<T>() method does not return any result when sending Expression<Func<T, bool>> to Where() Extension method
- LINQ to Entities: queryable extension method not reconized inside where condition
- Select() method not found in BindingList<T>, System.Linq is included
- Extension Method not compiling (No defintion for type 'string')
- Does not contain a definition for 'where' and the best extension method overload
- CS1061: 'IEnumerable<>' does not contain a definition for '' and no extension method '' accepting a first argument of type 'IEnumerable<>'
- Extension method & LINQ to Entities does not recognize the method error
- 'int' does not contain a definition for 'Contains' and the best extension method overload 'Queryable.Contains
- Linq extension method select not in
- Linq in conjunction with custom generic extension method build error - An expression tree may not contain an assignment operator?
- Could not find an implementation of the query pattern for source type 'System.Data.Entity.DbSet` 'Where' not found
- Why the extension method of where for LINQ in this code would print out a single number while it shouldn't print anything at all?
- Extension method (like Take()) not available for the LINQ query, Any reason why?
- Extension method not updating object passed in
- List ordering - Extension method not firing!
- Linq extension method equivalent for that code in VB.NET
More Query from same tag
- Comparing two list of objects and modifying a property
- Populating a List<class> from a query, results from List is address of the class
- Why is my update not persisting?
- Trying to create a lambda for filtering dates in linq to entities with additional complete check
- How to remove item from List<Tuple<DateTime, string>>
- Linq sort with Null values
- Why is OrderBy which returns IOrderedEnumerable<T> much faster than Sort?
- Flip grouping in LINQ
- How is this better than the Null Coalesce operator?
- How to filter on a list of keys in a Dictionary using LINQ
- How To Write Distance LINQ query i have Lat, Long in table with varchar type SQL Server
- how to optimize FirstOrDefault Statement in linq
- System.Linq.Dynamic - use SELECT inside WHERE statement
- Filter data with date that is stored as string instead of DateTime
- Output exception messages including all inners with LINQ
- Update a nested property with Linq
- How to get all Types using LINQ in Asp.net mvc
- Cross-Join Syntax in Entity Framework / IQueryable
- Issue Linq in entity framework?
- Dynamic select sentence with LINQ - Join 2 DataTables
- What's the System.Linq.Expressions.ExpressionVisitor.VisitExtension and the System.Linq.Expressions.ExpressionType.Extension for?
- Compare two json array in c# and get only the difference in separate object
- Linq To Entities [Unable to create a constant value of type '...']
- How do I use Linq for paging a generic collection?
- Thoroughly Check to see if an Email Exists, NHibernate, LINQ
- C# search values within range
- LINQ Query over another LINQ query
- Merging multiple List<CustomType> when grouping in LINQ
- Linq Group By Sum based on a condition
- LINQ Query to get data from another table