views:

236

answers:

1

When creating a DomainService, within .NET Ria Services and using Subsonic I can add a IQueryable method as follows:

public IQueryable<Server> GetServers() { return Server.All(); }

It compiles with no problem but when I add a method to get a specific server:

public IQueryable<Server> GetServer(int serverID) { return Server.SingleOrDefault( srv => srv.server_id == serverID); }

I get a "cannot implicitly convert type myApp.Data.Server to System.Linq.IQueryable.."

I've tried to append AsQueryable() to the end but that doesn't seem to work as myApp.Data.Server doesn't have that definition.

I'm at a loss of how to convert this to IQueryable, if it can.

+2  A: 

If you're returning a single Server entity, why would you want it to be a queryable? You've already found your entity... what queries would you execute on it?

If you really need to return a Queryable list of one item though, you can use the Find() method instead of SingleOrDefault(). SingleOrDefault's return value is simply the entity type, not an IQueryable.

womp
lol, right....been staring at screen too long
jdiaz