score:2

Accepted answer

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.


Related Query

More Query from same tag