Ok, this is very weird.
I'm using SubSonic 3.0 and Linq to select a list of IDs (and other properties) into a list of user-defined-objects. Like this:
public class ListItem
{
public int C { get; set; }
}
public class ListItemWithID
{
public int ID { get; set; }
}
then
var someList = (from m in mySubsonicRepository.GetQueryable() //IQueryable<myGeneratedClass>
select new ListItem { C = m.ID })
.ToList();
var someListWithID = (from m in mySubsonicRepository.GetQueryable()
select new ListItemWithID { ID = m.ID })
.ToList();
All the lists will have the same number of items. Problems is:
someList ... has all the C properties = 0
someListWithID has all the ID properties correctly set
How can this happen? The property of the ListItem will NOT be set to the correct value unless the name happens to be the same as th property from the enumerated class! (ie. C=m.ID does not work, but ID=m.ID does !!)
This behaviour only happens when using IQueryables from Subsonic... it does not happen when using (eg)
IList<SomeNonSubSonicClass> .AsQueryable()