Clean way to get related entities based on selection

I am using C# and EF 4. I have a Actor repository. The entity Actor has many to many relationship with Movie. So in the ActorReposity i'd like to have a method example GetActors whose salary is greater than 100 and also in the results i would like to include the movies that this actor has been in whose director is Doe.(director is property on the movie) the signiture of the method i have in the repository is IQueryable GetActors(). In this case i am just simpifying the signiture, After i get this to work then i can refactor to pass in parameters.

Answers


   public class ActorRepository       
   {
       public List<Actor> GetActors(int minimumSalary, string directorName)
       {
          return _ctx.Actors
                     .Include("Movies")
                     .Where(x => x.Salary > minimumSalary)
                     .Select(x => new 
                             {
                                Actor = x,
                                Movies = x.Movies.Where(y => y.DirectorName == directorName)
                             })
                     .ToList()
                     .Select(x => new Actor
                     {
                        // copy scalar properties from anon to Actor, e.g:
                        ActorName = x.ActorName,
                        // then set the Movies  navigational property to the filtered type
                        Movies = x.Movies
                     }).ToList()

       }
   }

Need Your Help

CSS sprite background does not shift

css background sprite

I have become increasing frustrated with what should be fairly simple CSS sprite code. I have been working on a map of counties that enlarges the county name when the mouse hovers over the link box

Javascript Named Function Expressions in Internet Explorer

javascript internet-explorer

Why does the following code not work in Internet Explorer (I've only tested in IE8 so far):

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.