0

Is there a way to implement a custom query design for a Navigation property, preferably using Fluent API?

I have seen several implementations using the Query Projections design pattern, but failed to find any that implement it at the property level. Most seem to be used off the context object of the Entity and not much off the Mapping framework.

Ideally looking to do something like this:

public class ArticleContent : IArticleContent {

    #region IArticleContent Members

    public Guid ArticleId { get; set; }
    public string Title { get; set; }
    public DateTime Version { get; set; }
    public Guid CreatedBy { get; set; }

    //Navigation Properties
    public User User { get; set; }
    public Article Article { get; set; }
    public ArticleContentRaw RawContent{get;set;}
    #endregion
}

public class ArticleRepository: IArticleRepository {
    public ArticleRepository(){
         Entity.RawContent = Context.ArticleContentRaw.OrderByDesc(acr => acr.CreatedBy);
    }
}

Although probably not syntactically correct but should get the idea acrossed.

GoldBishop
  • 2,820
  • 4
  • 47
  • 82
  • 1
    Im not really too sure what you are asking, can you clarify your question? – undefined Jan 01 '14 at 09:20
  • `Entity`, `RawContent`, `ArticleContentRaw`, Mapping framework, Query Projections design pattern ... explain, explain... – Gert Arnold Jan 01 '14 at 10:21
  • Instead of Entity Framework filling the Navigation properties, I want to put a LINQ style filler. Instead of putting All of the information that I mapped to the Property, maybe only a subset or a defined set of data. Query Projects seemed like a good fit but after reading about it, seemed to be a little more complicated for what I need, I thought. – GoldBishop Jan 02 '14 at 06:40

0 Answers0