views:

14

answers:

0

Hi,

I have a generic repository that uses the entity framework to manipulate the database.

The original code is credited to Morshed Anwar's post on CodeProject. I've taken his code and modified is slightly to fit my needs.

Unfortunately I'm unable to call an Imported Function because the function is only recognized for my specific instance of the entity framework

public class Repository<E, C> : IRepository<E, C>, IDisposable
    where E : EntityObject
    where C : ObjectContext
{
    private readonly C _ctx;

    public ObjectResult<MyObject> CallFunction()
    {
        // This does not work because "CallSomeImportedFunction" only works on
        // My object. I also cannot cast it (TrackItDBEntities)_ctx.CallSomeImportedFunction(); 
        // Not really sure why though... but either way that kind of ruins the genericness off it.
        return _ctx.CallSomeImportedFunction();
    }
}

Anyone know how I can make this work with the repository I already have? Or does anyone know a generic way of calling stored procedures with entity framework?

Thanks,
Matt