PI2024-23 #2
@ -13,10 +13,15 @@ namespace FirmTracker_Server.nHibernate.Reports
|
||||
public virtual decimal TotalExpenses { get; set; }
|
||||
public virtual decimal TotalBalance { get; set; }
|
||||
|
||||
public virtual IList<ReportTransaction> ReportTransactions { get; set; } = new List<ReportTransaction>();
|
||||
/*public virtual IList<ReportTransaction> ReportTransactions { get; set; } = new List<ReportTransaction>();
|
||||
public virtual IList<ReportExpense> ReportExpenses { get; set; } = new List<ReportExpense>();
|
||||
|
||||
|
||||
public Report()
|
||||
{
|
||||
ReportTransactions = new List<ReportTransaction>();
|
||||
ReportExpenses = new List<ReportExpense>();
|
||||
}*/
|
||||
|
||||
|
||||
public class DateRangeDto
|
||||
|
@ -13,13 +13,15 @@ namespace FirmTracker_Server.nHibernate.Reports
|
||||
Map(x => x.TotalExpenses);
|
||||
Map(x => x.TotalBalance);
|
||||
|
||||
HasMany(x => x.ReportTransactions)
|
||||
.Cascade.All()
|
||||
.Inverse();
|
||||
/*HasMany(x => x.ReportTransactions)
|
||||
.KeyColumn("ReportId")
|
||||
.Cascade.AllDeleteOrphan()
|
||||
.Inverse();
|
||||
|
||||
HasMany(x => x.ReportExpenses)
|
||||
.Cascade.All()
|
||||
.Inverse();
|
||||
.KeyColumn("ReportId")
|
||||
.Cascade.AllDeleteOrphan()
|
||||
.Inverse();*/
|
||||
|
||||
}
|
||||
|
||||
|
@ -4,22 +4,32 @@ namespace FirmTracker_Server.nHibernate.Reports
|
||||
{
|
||||
public class ReportExpense
|
||||
{
|
||||
public virtual int Id { get; set; }
|
||||
public virtual int ReportId { get; set; }
|
||||
public virtual int ExpenseId { get; set; }
|
||||
//public virtual int Id { get; set; }
|
||||
public virtual Report Report { get; set; }
|
||||
public virtual Expense Expense { get; set; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null || GetType() != obj.GetType())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var other = (ReportExpense)obj;
|
||||
return ReportId == other.ReportId && ExpenseId == other.ExpenseId;
|
||||
return Report != null && Expense != null &&
|
||||
Report.Id == other.Report.Id &&
|
||||
Expense.Id == other.Expense.Id;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(ReportId, ExpenseId);
|
||||
unchecked // Overflow is fine, just wrap
|
||||
{
|
||||
int hash = 17;
|
||||
hash = hash * 23 + (Report?.Id.GetHashCode() ?? 0);
|
||||
hash = hash * 23 + (Expense?.Id.GetHashCode() ?? 0);
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,9 +7,9 @@ namespace FirmTracker_Server.nHibernate.Reports
|
||||
public ReportExpenseMapping()
|
||||
{
|
||||
Table("ReportExpenses");
|
||||
Id(x => x.Id);
|
||||
References(x => x.ReportId, "ReportId");
|
||||
References(x => x.ExpenseId, "ExpenseId");
|
||||
CompositeId()
|
||||
.KeyReference(x => x.Report, "ReportId")
|
||||
.KeyReference(x => x.Expense, "ExpenseId");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,22 +4,32 @@ namespace FirmTracker_Server.nHibernate.Reports
|
||||
{
|
||||
public class ReportTransaction
|
||||
{
|
||||
public virtual int Id { get; set; }
|
||||
public virtual int ReportId { get; set; }
|
||||
public virtual int TransactionId { get; set; }
|
||||
//public virtual int Id { get; set; }
|
||||
public virtual Report Report { get; set; }
|
||||
public virtual Transaction Transaction { get; set; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null || GetType() != obj.GetType())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var other = (ReportTransaction)obj;
|
||||
return ReportId == other.ReportId && TransactionId == other.TransactionId;
|
||||
return Report != null && Transaction != null &&
|
||||
Report.Id == other.Report.Id &&
|
||||
Transaction.Id == other.Transaction.Id;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(ReportId, TransactionId);
|
||||
unchecked // Overflow is fine, just wrap
|
||||
{
|
||||
int hash = 17;
|
||||
hash = hash * 23 + (Report?.Id.GetHashCode() ?? 0);
|
||||
hash = hash * 23 + (Transaction?.Id.GetHashCode() ?? 0);
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,12 +4,12 @@ namespace FirmTracker_Server.nHibernate.Reports
|
||||
{
|
||||
public class ReportTransactionMapping : ClassMap<ReportTransaction>
|
||||
{
|
||||
public ReportTransactionMapping()
|
||||
public ReportTransactionMapping()
|
||||
{
|
||||
Table("ReportTransactions");
|
||||
Id(x => x.Id);
|
||||
References(x => x.ReportId, "ReportId");
|
||||
References(x => x.TransactionId, "TransactionId");
|
||||
CompositeId()
|
||||
.KeyReference(x => x.Report, "ReportId")
|
||||
.KeyReference(x => x.Transaction, "TransactionId");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user