Using linq select to provide a grid datasource, properties are read-only
I am using the return from the following call as the datasource for a grid.
public object GetPropertyDataSourceWithCheckBox( )
开发者_开发技巧 {
return (
from p in LocalProperties
join c in GetCities( ) on p.CityID equals c.CityID
orderby p.StreetNumber
select new { Selected = false, p.PropertyID, p.StreetNumber, p.StreetName, c.CityName } ).ToList( );
}
I get a checkbox in the grid, but it is READ-ONLY. [For the record, the grid is DevExpress.] Is there a way around this, short of creating a non-anonymous class?
Continuing research tells me that, in fact, anonymous classes returned by linq are always read-only, so, apparently, creating an actual class is best (only?) solution.
精彩评论