c# - EF Relationships and Specification Pattern -


I see in the specification pattern for my repository, I use EF4 in my repository to query the database Maping selected organizations by passing in an expression, doing something like this: -

  public IEnumerable & lt; Tentity & gt; Find (expression & lt; funk & lt; tntti, boyoy & gt; count) {return _objectSet.Where & lt; Tanti & gt; (Forecast); }   

It works fine if you work with an object set but say whether you want to select all the comments made by the user more than 128 times and The user is active.

Example: -

  class user {public string name {get; Set; } Public Bull Active {get; Set; } Public virtual iconenging & lt; Post & gt; Post {get; Set; } Public User () {Mail = New List & lt; Post & gt; (); }} Class post {public string text {get; Set; } Public Date Time Created (Receive; Set;} Public Virtual Icoding & lt; Comment & gt; Comments {get; Set;} Public Post () {Comments = New List & lt; Comment & gt; ();}} Class comment {public string text {get} set;} made public date time (get; set;}}   

to do this in Linq: -

  results in the results from = P in P. P. Posted in P. Comments where U. Choose R & amp; amp; C.Text.Length & gt; 128; C;   

Then how can you change it in a specification class? Maybe I am not seeing anything because that

Edit

Specification Interface:

  Public Interface ISPCification & lt; TENTITY & gt; {Bool istified bide (TNTITY Entity);}    

First of all Current setup does not allow such queries Because user and Note are not related to you can only select all comments related to posts related to the user, but what post comments that you do not know.

Just user and comment and you can use just:

  var result = from the reference C.Comments where c.user.activ and c.Text.Length & gt; Select 128C;   

This will be easily possible in your specification pattern. Anyway, if you want to create a complex situation with your comment method, you need to expose the navigation properties to allow it.

Comments