I'm getting an error about "could not set a property value by reflection setter of GpisReplacement.Domain.Phase.Id" when I go to commit a transaction. I've double-checked and that class has a public setter for that property. I've also double-checked that all my classes have a public or protected default constructor per a stack-overflow post I found. Are there any other things that could cause this error? Relevant files are attached.
-- You received this message because you are subscribed to the Google Groups "nhusers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/nhusers. For more options, visit https://groups.google.com/d/optout.
Phase.hbm.xml
Description: XML document
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using GpisReplacement.Arch;
using GpisReplacement.Domain.Enums;
namespace GpisReplacement.Domain
{
public class Phase
{
public Phase()
{
Contacts = new HashSet<PhaseContact>();
Districts = new HashSet<District>();
PhaseLocations = new HashSet<ProjectLocation>();
}
public virtual long Id { get; set; }
public virtual Project Project { get; set; }
public virtual PhaseName PhaseName { get; set; }
[Display(Name = "Estimated Start")]
public virtual DateTime? EstStartDate { get; set; }
[Display(Name = "Estimated End")]
public virtual DateTime? EstEndDate { get; set; }
[Display(Name = "Actual Start")]
public virtual DateTime? ActStartDate { get; set; }
[Display(Name = "Actual End")]
public virtual DateTime? ActEndDate { get; set; }
public virtual bool IsCurrentPhase { get; set; }
public virtual ICollection<ProjectLocation> PhaseLocations { get; set; }
public virtual ICollection<PhaseContact> Contacts { get; set; }
public virtual ICollection<District> Districts { get; set; }
public virtual DateTime StartDate { get; protected set; }
public virtual DateTime EndDate { get; protected set; }
public virtual void AddLocation(ProjectLocation clone)
{
clone.Phase = this;
clone.Project = this.Project;
this.PhaseLocations.Add(clone);
}
//public virtual void AddContact(Contact contact)
//{
// if (!Contacts.Contains(contact))
// {
// this.Contacts.Add(contact);
// }
//}
public virtual void AddDistrict(District district)
{
if (!this.Districts.Contains(district))
{
this.Districts.Add(district);
}
if (!district.Phases.Contains(this))
{
district.Phases.Add(this);
}
}
public virtual Project GetProject()
{
return this.Project;
}
/// <summary>
/// Gets a list of PAOneCalls for all locations for this phase.
/// </summary>
/// <returns>Only distinct number/type combinations are returned.</returns>
public virtual IEnumerable<LocationPAOneCall> GetPhaseDistinctPaOneCalls()
{
var l = new List<LocationPAOneCall>();
foreach (var projectLocation in PhaseLocations)
{
if (projectLocation.PAOneCallNumbers == null || !projectLocation.PAOneCallNumbers.Any()) continue;
foreach (var oneCall in projectLocation.PAOneCallNumbers)
{
//looking for new number/type combo
if (!l.Exists(call => call.Number == oneCall.Number && call.OneCallType == oneCall.OneCallType))
{
l.Add(oneCall);
}
}
}
return l;
}
public virtual void AddContact(Contact contact, bool isPrimary)
{
if(contact == null) throw new ArgumentNullException("contact");
var pcm = new PhaseContact
{
//Project = Project,
Phase = this,
Contact = contact
};
contact.ProjectPhases.Add(pcm);
Contacts.Add(pcm);
}
public virtual void RemoveContact(Contact contact)
{
if (contact == null) throw new ArgumentNullException("contact");
var pcm = Contacts.First(c => c.Contact.Id == contact.Id);
contact.ProjectPhases.Remove(pcm);
Contacts.Remove(pcm);
}
}
}
