Subsonic IQueryable Output

We have this:

repository.Add<Customer>(c);
...
IQueryable<Customer> result1 = repository.All<Customer>();
Console.WriteLine( result1.Count() );
IQueryable<ICustomer> result2 = result1.Cast<ICustomer>();
Console.WriteLine( result2.Count() ); // error here

This gives the following error:

An expression of type "System.Collections.Generic.IEnumerable`1 [Data.Customer]" cannot be used for a parameter of type "System.Linq.IQueryable" of the method "System.Linq.IQueryable`1 [Data.ICustomer] Cast [ICustomer]] (System.Linq.IQueryable) '

Is it possible to work through interfaces?

+3
source share

Source: https://habr.com/ru/post/1713231/


All Articles