Hello,
I have a database repository with a bunch of access functions. I now want to build a fake repository which provides similar functionality for unittests. Unlike the real repository, this one uses simple lists instead of linqtosql generated model classes.
Most fake repository funtions look exactly like the real ones, just with an extra ToQueryable() at the end. However, I now have one that seems to require a more complicated cast.
public class FakeUserRepository : IUserRepository {
public IQueryable<SelectListItem> GetRecords(int userid) {
// fake_table is a list
return (from a in fake_table select
new SelectListItem {
Value = a.ID.ToString(),
Text = a.Name
});
}
}
Currently, this gives the error "Cannot implicitly convert type 'System.Collections.Generic.IEnumerable.) I am not surprised by the error message but I have no idea how fix the cast.
Thanks for your help!