following is the code working fine in local system but throwing error in server...
public class Employee
{
public virtual Int32 Emp_ID { get; set; }
public virtual String Name { get; set; }
public virtual String Email { get; set; }
public virtual String Mobile { get; set; }
public virtual String Address { get; set; }
public virtual String Username { get; set; }
public virtual String Password { get; set; }
public virtual String Designation { get; set; }
public virtual String Reference { get; set; }
public virtual Boolean IsWorking{get;set;}
public virtual IList<Timesheet> Timesheet { get; set; }
#region Object Overrides
/// <summary>
/// Method that checkes if the given User instance is equivalent to the current User Instance
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public override bool Equals(object obj)
{
if (obj is Timesheet)
{
Timesheet compareTo = (Timesheet)obj;
return compareTo.Timesheet_ID.Equals(this.Timesheet);
}
else
{
return base.Equals(obj);
}
}
/// <summary>
/// ToString of Product Instance returns the Product Code
/// instead of the Itme Object's String representation
/// </summary>
/// <returns></returns>
public override string ToString()
{
return this.Name;
}
/// <summary>
/// Method that gets the Hash Code of the Object's Unique Identifier
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
return this.Emp_ID.GetHashCode();
}
#endregion
}
public class Timesheet
{
public virtual Int32 Timesheet_ID { get; set; }
public virtual Employee Employee { get; set; }
public virtual Client Client { get; set; }
public virtual Project Project { get; set; }
public virtual Activity Activity { get; set; }
public virtual DateTime Date { get; set; }
public virtual String TimeSpent { get; set; }
public virtual String Comments { get; set; }
public virtual Boolean IsApproved { get; set; }
public Timesheet()
{
Employee = new Employee();
}
}
related mapping classes are
public class EmployeeMap : ClassMap<Employee>
{
public EmployeeMap()
{
// Table name as in database
Table("tblEmployee");
// Fields mapping to the Database
Id(x => x.Emp_ID).GeneratedBy.Increment();
Map(x => x.Name);
Map(x => x.Email);
Map(x => x.Mobile);
Map(x => x.Address);
Map(x => x.Username);
Map(x => x.Password);
Map(x => x.Designation);
Map(x => x.Reference);
Map(x => x.IsWorking);
HasManyToMany(x => x.Timesheet).Table("tblEmpTimesheet").ParentKeyColumn("Emp_ID").ChildKeyColumn("Timesheet_ID");
}
public class TimesheetMap
{
public TimesheetMap()
{
// Table name as in database
Table("tblEmpTimesheet");
// Fields mapping to the Database
Id(x => x.Timesheet_ID).GeneratedBy.Increment();
Map(x => x.Date);
Map(x => x.TimeSpent);
Map(x => x.Comments);
Map(x => x.IsApproved).Default("false");
// Relationships with Other Objects
References<Employee>(x => x.Employee).Column("Emp_ID");
}
}
throwing security exception error when i try to access emplyee from timesheet or viceversa..
IQuery query = session.CreateQuery(String.Format("from {0} where {1} ='{2}'", "Timesheet", "Employee", 1));
IList<Timesheet> timeSheet= query.List<Timesheet>();
It seems your server is running your web application within a medium trusted context. This requires you to change a few settings in nhibernate to get nh running.
Most likely the castle proxy stuff is the bad guy...
Try to follow the steps explained here .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.