this should be fast for all of you f # rockers, but it made me stuck at the moment.
I have an F # type that I am trying to implement for a C # interface
public interface ICrudService<T> where T: DelEntity, new() { IEnumerable<T> GetAll(); }
here, as implemented in C #:
public IEnumerable<T> GetAll() { return repo.GetAll(); }
repo.GetAll returns IQueryable , but the C # compiler knows enough to convert it to IEnumerable , because IQueryable<T> : IEnumerable<T> . but in F # the compiler cannot handle it, and I tried several attempts to do it right.
type CrudService<'T when 'T :(new : unit -> 'T) and 'T :> DelEntity>(repo : IRepo<'T>) = interface ICrudService<'T> with member this.GetAll () = repo.GetAll<'T>
this gives me a type mismatch error
casting f #
Jonny cundall
source share