You could do something like this: public class MyRepository { private List mItems; public IEnumerable GetAllItems() { return this. MItems; } public IEnumerable GetGoodItems() { return this.GetAllItems(). Where(x => x.
IsGood == true); } public IEnumerable GetGoodItemsOverFiveDollars() { return this.GetGoodItems(). Where(x => x. Price > 5.00m); } } public class Item { public bool IsGood { get; set; } public decimal Price { get; set; } } You can do this because the query is not executed until the enumeration is evaluated.
However, keep in mind that additional linq statements can be added outside the MyRepository class, and thus you can have "linq injection" ;). You could avoid this by wrapping the methods and making them internal, where your wrapping methods call ToList or ToArray, allowing the query to execute. How are you currently executing your queries, and what repetition are you trying to reduce?
Can you provide an example?
Oops, trying to format code as code... – Jim Apr 12 at 2:22 ok. I did that (but some strange way). I have an idea to put that linq2sql shared query as an extension method of my DataContext.
Isn't it a good way? – Jim Apr 12 at 2:30 Normally, I would consider placing your queries in the repository itself, unless your extensions are very domain specific, and you're trying to avoid creating multiple repositories for the same database. – xixonia Apr 12 at 3:05.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.