views:

21

answers:

1

I have the following piece of code

public static Func<PurchasingDataContext, int, int, List<Requisition>>
    GetRequisitions = CompiledQuery.Compile((PurchasingDataContext context, int userid, int requisitionState)
        => context.Requisitions.Where(r => r.UserId == userid && r.RequisitionId == requisitionState).ToList());

    public static List<Requisition> GetRequisitions(int userid, int requisitionState)
    {
        using (PurchasingDataContext context = new PurchasingDataContext())
        {
            return GetRequisitions(context, userid, (int)requisitionState);
        }
    }

and it is producing the following error:

The type 'Purchasing.Data.Requisition' already contains a definition for 'GetRequisitions'

I dont really understand why, I had assumed, perhaps incorrectly that a Func was a method. In which case I am just overloading here. Perhaps it is different, or I am just doing something wrong. Any advice would be great thanks

Will

+2  A: 

You have a field called GetRequisitions (your Func delegate) and you have a method of the same name. That is never allowed.

Kirk Woll
So a func is a property in this case? It is not a method?
Wdhough
@Wdhough neither property nor method - a *field*, like `public int i;`
AakashM
Wow, well, you learn something new everyday, thanks guys
Wdhough
@wdhough - you should mark this as the answer, if it's answered your question
Grant Crofton