score:2
in .net 3.5, there exists a static enumerable
existing in system.linq
, which contains extension methods for manipulating ienumerable
s - 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.
Source: stackoverflow.com
Related Query
- Return Enumerable value from Class in linq?
- How to understand the following C# linq code of implementing the algorithm to return all combinations of k elements from n
- LINQ to Entities - How to return a single string value from entity
- How to Deal With Dapper return Key Value pair with Dynamic from LINQ
- creating Linq to sqlite dbml from DbLinq source code
- return a class directly from a linq query
- Linq return WhereEnumerableIterator from Dictionary value matches?
- How can I return a list or enumerable of rows where column value has changed with Linq
- how to return a value from a LINQ statement
- LINQ - Return Value From Field With A Max Value if No Rows Found
- Can't add a new record with an integer value into database by using linq from code C#
- Can I receive both the return value and resultset from a procedure using Linq to sql?
- Is it possible to return a return value and a result set from a stored procedure using LINQ
- LINQ function to return list but compiler says function doesn't return a value on all code path
- how to use linq to return a value from 4 tables
- How can I return a single value integer from Linq from an array of objects that have other nested values
- I get a query string as return value from LINQ to SQL and WCF Services and no concrete value
- How do i return a value from LINQ into a parameter? C#
- returning multiple class model data from linq in list via return method in C#
- Access to the return value from the database by linq
- How to return value from 2 tables in one linq query
- c# Linq or code to extract groups from a single list of source data
- LINQ return value conversion failed from string to int
- How to return sum value from using group by, having and sum by using LINQ in C#
- Using Linq to Order by Descending from a Method Return value
- How to built a dictionnary from linq query with Id as Key and Data Class as Value in c#?
- Find a certain value from a source collection in a target collection of different type with linq
- Returning a custom list class type from LINQ Query - return same type going in that is coming out
- Using C# Linq find and return a string value from a multi-level data store
- How can I get LINQ to return the object which has the max value for a given property?
More Query from same tag
- Query Slow in Linq, Fast in LinqPad, SQL Management Studio and SQL Profiler
- Linq grouping .include("Table") returning null on Table
- Get the current index position in a list when creating a new object in a linq expression
- LINQ operation with ternary operation causing tests to fail if logic is swapped
- C# linq remove duplicates from the top and bottom of the list and keep the duplicates in the middle
- How to flatten a multi level XML into a single level XML using c# code LINQ
- LINQ for two tables where date range between two values
- How to know whether there is a round has been caused by parents (A=>B=>C=>A)
- How do I update a field of a record using linq
- Linq2Sql Contains
- How to translate the following SQL to Linq?
- Incorrect Model Type from my View
- Moq.Verify appears broken with Linq.Select usage
- How to calculate "total" using Javascript and SQL?
- T-SQL to LINQ Query (Many to Many filter)
- Compare swapped two list of each value using linq in c#
- How to convert a flat data collection into hierarchical one?
- Dynamically Entering "select" by a string in LINQ Query
- Newbie issue with LINQ in vb.net
- Using LINQ get all possible pair of connections from two lists
- LINQ to Razor View SubQuery with Alias Value
- LINQ to SQL Left Outer Join
- linq null parameter
- Convert SQL subselect to LINQ
- EntityFramework with WEB API, update all properties
- Check if string already exist in Table
- Find records that contains at least one word of a string
- Object reference not set to an instance of an object. Adding Two Table using LinQ in datagridview Entity Framework
- LINQ Many to Many With In or Contains Clause (and a twist)
- how to speed up linq query on csv imported list