So I thought I'd try something a bit clever/stupid in my datalayer. I'm using Jon Wagner's Insight.Database but most of my tables have a set of CRUD operations. So I figured, why not do this :
public interface IDataInterface<T>
{
Task<T> SelectAsync(int id);
Task<IEnumerable<T>> SelectAsync();
Task<int> UpsertAsync(T obj);
Task<bool> UpsertManyAsync(IEnumerable<T> list);
Task<bool> DeleteAsync(int id);
Task<bool> DeleteManyAsync(IEnumerable<T> list);
}
and then I thought I could do something like this :
[Sql(Schema = "Clients")]
public interface IClientDataInterface : IDataInterface<Client>
{
}
with all my stored procedures relating to the Clients table in a Clients schema.
However, this doesn't work and poking through the InnerExceptions until I finally hit paydirt, I got the following error -
InnerException = {"The stored procedure 'Select' doesn't exist."}
Even though Clients.Select definitely exists.
This indicates to me that the base interface (which has no [Sql] annotation) has a default of [Sql(Schema="dbo")] which is inherited and overrides any later annotation.
Is this right? Is there a way to disable the base Schema if it it's right? If not, what's going on?
Bit late getting back to this, but...
Nope. Insight doesn't inherit [Sql] annotations.
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Interface)]
I guess this is just one of those nice little tricks that won't work the way we all wish it would.