54v054r3n
54v054r3n

Reputation: 394

Navigation property with complex filtering criteria using Entity Framework

I use the Entity Framework 4 to migrate a legacy application to C #. The data model consists of two tables, "Appointment" and "Authorization", which are in a one to many relationship. In the conceptual model, the classes are properly represented. Also the navigation property "Appointment.Authorizations" works so far correct.

But I want the navigation property "Appointment.Authorizations" only objects of class Authorization are listed that meet certain criteria. The criteria can be very complex. Expressed in SQL, there are about 30 lines of code. Several other tables are also involved in the query.

enter image description here

Which method is best for now to change the behavior of the navigation property, so that only the desired selection is listed? A read only Collection would be ok.

Upvotes: 3

Views: 274

Answers (1)

Isuru Fonseka
Isuru Fonseka

Reputation: 601

The navigation property looks okay, what your describing is business logic keep it out of the SQL and in the C#, where you can write unit tests against this logic.

If you can provide more information about the "select" logic and provide some code we can help you get in the right direction.

Upvotes: 1

Related Questions