score:2

Accepted answer

in .net 3.5, there exists a static enumerable existing in system.linq, which contains extension methods for manipulating ienumerables - this is not what you want to (or clearly can) return. change it to ienumerable, which is the non-generic enumerable class (and what i think you intend), and all should work fine.

even better, use the generic version of ienumerable, as such:

public static ienumerable<stuffdepartman> loaddatabyname(string name)
{
    var stuffs = (list<stuffdepartman>)httpcontext.current.session["stuffs"];

    return (from s in stuffs where s.name == name select s.name);
}

also, note that you don't need the call to asenumerable before returning, since list<t> implements ienumerable<t>, and the former can be implicitly casted to the latter. the = needed to be changed to ==, since you want to use the equality rather than assigment operator here. the other changes are just tidying up.

score:0

enumerable is a static class, what you want to do is return an ienumerable:

    public static  ienumerable<string>  loaddatabyname(string name)
    {
      //do stuff
    }

i'm assuming s.name in your example is a string, which is why the method should return ienumerable<string>. if it's another type, then change it to that type....

edit: ok, i guess it's not a string. change it to:

    public static  ienumerable<stuffdepartman>  loaddatabyname(string name)
    {
      //do stuff
    }

score:1

system.linq.enumerable is a static class with a bunch of extension methods defined on it. you perhaps meant to return ienumerable<string> instead.


Related Query

More Query from same tag