Asked by:
Filtering Records Displayed in a Joining Table

Question
-
User2074931137 posted
Question Illustrated in a PDF <- Best representation of project / question
Error 1 The type or namespace name 'Assignments' could not be found (are you missing a using directive or an assembly reference?) D:\_Data\MVC\_fvm\00. fvm\fvm\fvm\Controllers\Assignment1Controller.cs 549 24 fvm
IQueryable<Assignments> assignments = from s in db.Assignments where Assignment.AssignmentContact != Contact.ContactDesignator1String || Assignment.AssignmentRoute != Route.RouteDesignatorString || Assignment.AssignmentVehicle != Resource.ResourceDesignatorString select s; assignments.Include(a => a.Calendar) .Include(a => a.Charter) .Include(a => a.Contact) .Include(a => a.HistoryEmployee) .Include(a => a.HistoryResource) .Include(a => a.Resource) .Include(a => a.ResourceDirection) .Include(a => a.ResourceDocument) .Include(a => a.ResourceOffice) .Include(a => a.Route);
I got this far with a great deal of help. Can anyone offer any further insight into how I might make this work?
Friday, October 26, 2018 3:00 PM
All replies
-
User475983607 posted
It is my fault for you going down this path... However, this code is just incorrect.
IQueryable<Assignments> assignments = from s in db.Assignments where Assignment.AssignmentContact != Contact.ContactDesignator1String || Assignment.AssignmentRoute != Route.RouteDesignatorString || Assignment.AssignmentVehicle != Resource.ResourceDesignatorString select s;
You need to rethink the approach.
Friday, October 26, 2018 3:06 PM -
User2074931137 posted
Thank you so much for the effort.
I don't have a lot of options for a different approach with my limited coding ability / experience (I'm working at an entry level modifying the intro tutorial).
I did want to provide an accurate representation of the question and code (which I provided at the link below).Question Illustrated in a PDF <- Best representation of project / question
From my limited ability / understanding: the fields that need to be compared are already in the joining table ("Assignment") controller and index view. I don't understand why they can't be used to filter the records displayed (again, my ability / understanding of this is limited).
Again, I really appreciate all the effort you've made.
Friday, October 26, 2018 3:22 PM -
User2074931137 posted
Note: The question in this question string remains unanswered
Question Illustrated in a PDF <- Best representation of project / question
__________________________________________________________________
Would it make any difference if I have the comparison properties for Route, Resource, and Contact in the same tables - Route, Resource, and Contact (not in the joining (“Assignments”) table?
e.g.where route.RouteDesignatorString = ! route.RouteComparison || resource.ResourceDesignatoString = ! resource.ResourceComparison || contact.ContactDesignatorString = ! contact.ContactComparison
Saturday, October 27, 2018 12:44 AM -
User1520731567 posted
Hi 3v3rhart,
As I can see in your code, I didn't see any relationships between the comparison properties which from Route, Resource, and Contact and properties from joining (“Assignments”) table.
where route.RouteDesignatorString = ! route.RouteComparison || resource.ResourceDesignatoString = ! resource.ResourceComparison || contact.ContactDesignatorString = ! contact.ContactComparison
I think you could change your model design.Please refer to:
Best Regards.
Yuki Tao
Monday, October 29, 2018 3:18 AM -
User2074931137 posted
<br>
There is a many to many relationship between Route, Resource, and Contact; Assignment is the joining table.Monday, October 29, 2018 12:33 PM -
User1520731567 posted
Hi 3v3rhart,
3v3rhart
There is a many to many relationship between Route, Resource, and Contact; Assignment is the joining table.The link I post also has many to many:
or refer to:
https://www.codeproject.com/Articles/702890/MVC-Entity-Framework-and-Many-to-Many-Relation
Best Regards.
Yuki Tao
Tuesday, October 30, 2018 1:46 AM -
User2074931137 posted
Note: The question in this question string remains unanswered
Question Illustrated in a PDF <- Best representation of project / question
__________________________________________________________________
Would it make any difference if I have the comparison properties for Route, Resource, and Contact in the same tables - Route, Resource, and Contact (not in the joining (“Assignments”) table?
e.g.where route.RouteDesignatorString = ! route.RouteComparison || resource.ResourceDesignatoString = ! resource.ResourceComparison || contact.ContactDesignatorString = ! contact.ContactComparison
Thursday, November 15, 2018 6:47 PM