I use stored procedures in Entity Framework. Let’s say that I have that procedure:
public static int DoSth(decimal id)
{
return (int)Adapter.my_proc(id).First();
}
as I don’t want to get the First() element and then cast it as (int) everytime I’d like to have an extension method which do that for me (gets the First element and then cast it as a T). How will it looks like ?
I’m not sure I understand what is your problem. Here is the code for simple extension method that takes
ObjectResult<T>, gets first element of collections and cast it to T (put the method in separate static class).And then you can call it like:
Is that what you’re thinking of?