Is there a way to define somthing in my assembly along the lines of
MyQuery<T> = Expression<Func<IQueryable<T>, IQueryable<T>>>
I'm feed up of typing this over and over again!
Cheers,
Stephen.
Loading User Information from Channel 9
Something went wrong getting user information from Channel 9
Loading User Information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
Is there a way to define somthing in my assembly along the lines of
MyQuery<T> = Expression<Func<IQueryable<T>, IQueryable<T>>>
I'm feed up of typing this over and over again!
Cheers,
Stephen.
I don't know any way. You can declare alias with a using-directive.
using MyQuery = System.Linq.Expressions.Expression<System.Func<System.Linq.IQueryable<int>, System.Linq.IQueryable<int>>>;
However it doesn't work to declare a 'generic' alias
:
// Does NOT work =( using MyQuery<T> = System.Linq.Expressions.Expression<System.Func<System.Linq.IQueryable<T>, System.Linq.IQueryable<T>>>;
static global method that acts as a Factory?
Foo<T>();
or Foo<T>( TypeThing T);
that retun an instance of the target Type ?
figuerres said:static global method that acts as a Factory?
Foo<T>();
or Foo<T>( TypeThing T);
that retun an instance of the target Type ?
About the best option I settled on was something along the lines of as static method on a class
public static Expression<Func<IQueryable<T>, IQueryable<T>>> CreateQuery<T>(Expression<Func<IQueryable<T>, IQueryable<T>>> spec)
{
return spec;
}
And then in the app code
var spec = DataRepository.CreateQuery<User>((x) => from u in x where u.FirstName == firstname select u) ;
Seems the best compromise for readability in the app code.
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.