Reputation: 111
I have a model
:
public class Parameter
{
[Key]
public int paramID { get; set; }
[Display(Name = "No.")]
public int paramNo { get; set; }
[Required]
[Display(Name = "Title")]
public string parameter { get; set; }
[Display(Name = "Meaning")]
public string description { get; set; }
[Display(Name = "Synonym")]
public string synonym { get; set; }
public int catID { get; set; }
public virtual ICollection<CompareParameter> CompareParameters { get; set; }
}
I need to add a model that compares all objects in the Parameter with each of the other objects in Parameter. So far I have this:
public class CompareParameter
{
[Key]
public int CompareID { get; set; }
public int paramID1 { get; set; }
public int paramID2 { get; set; }
public virtual Parameter Parameters { get; set; }
public virtual Parameter Parameters2 { get; set; }
}
Where paramID1
takes the key from Parameter and paramID2
does the same. Only it does not appear to be working at the moment.
Any ideas?
=== Update Question ===
With the two models I have given as examples, what should I do about CompareParameter
to allow me to build a controller and a view that will have two dropdowns of the same class. The purpose of this is so that I can link it to another class with possible outcomes.
Upvotes: 0
Views: 87
Reputation: 504
You should derive your Parameter class from Comparer and implement the comparison that way.
Upvotes: 1