PI2024-23 #2
@ -1,4 +1,6 @@
|
||||
namespace FirmTracker_Server.nHibernate.Expenses
|
||||
using FirmTracker_Server.nHibernate.Reports;
|
||||
|
||||
namespace FirmTracker_Server.nHibernate.Expenses
|
||||
{
|
||||
public class Expense
|
||||
{
|
||||
@ -6,5 +8,6 @@
|
||||
public virtual DateTime Date { get; set; }
|
||||
public virtual decimal Value { get; set; }
|
||||
public virtual string Description { get; set; }
|
||||
public virtual IList<Report> Reports { get; set; } = new List<Report>();
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,12 @@ namespace FirmTracker_Server.nHibernate.Expenses
|
||||
Map(x => x.Value);
|
||||
Map(x => x.Description);
|
||||
|
||||
HasManyToMany(x => x.Reports)
|
||||
.Cascade.All()
|
||||
.Table("ReportExpenses")
|
||||
.ParentKeyColumn("ExpenseId")
|
||||
.ChildKeyColumn("ReportId");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
using FirmTracker_Server.nHibernate.Expenses;
|
||||
using FirmTracker_Server.nHibernate.Transactions;
|
||||
|
||||
namespace FirmTracker_Server.nHIbernate.Reports
|
||||
namespace FirmTracker_Server.nHibernate.Reports
|
||||
{
|
||||
public class Report
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
using FluentNHibernate.Mapping;
|
||||
namespace FirmTracker_Server.nHIbernate.Reports
|
||||
namespace FirmTracker_Server.nHibernate.Reports
|
||||
{
|
||||
public class ReportMapping : ClassMap<Report>
|
||||
{
|
||||
|
@ -33,7 +33,8 @@ namespace FirmTracker_Server.nHibernate
|
||||
.AddFromAssemblyOf<Transactions.TransactionProductMapping>()
|
||||
.AddFromAssemblyOf<Transactions.Transaction2Mapping>()
|
||||
.AddFromAssemblyOf<Transactions.TransactionWithProductsMapping>()
|
||||
.AddFromAssemblyOf<Expenses.ExpenseMapping>();
|
||||
.AddFromAssemblyOf<Expenses.ExpenseMapping>()
|
||||
.AddFromAssemblyOf<Reports.ReportMapping>();
|
||||
})
|
||||
.ExposeConfiguration(cfg => new SchemaExport(cfg).Create(true, true)) //SchemaUpdate . Execute dla only update
|
||||
.BuildSessionFactory();
|
||||
|
@ -1,4 +1,5 @@
|
||||
using FirmTracker_Server.nHibernate.Products;
|
||||
using FirmTracker_Server.nHibernate.Reports;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -15,6 +16,7 @@ namespace FirmTracker_Server.nHibernate.Transactions
|
||||
public virtual decimal Discount { get; set; }
|
||||
public virtual string Description { get; set; }
|
||||
public virtual decimal TotalPrice { get; set; }//=> TransactionProducts.Sum(tp => ((tp.Quantity * tp.UnitPrice)* ((1 - (Discount / 100)))));// (1 - (Discount / 100)));
|
||||
public virtual IList<Report> Reports { get; set; } = new List<Report>();
|
||||
|
||||
public Transaction()
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
using FirmTracker_Server.nHibernate.Products;
|
||||
using FirmTracker_Server.nHibernate.Reports;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -15,6 +16,7 @@ namespace FirmTracker_Server.nHibernate.Transactions
|
||||
public virtual decimal Discount { get; set; }
|
||||
public virtual string Description { get; set; }
|
||||
public virtual decimal TotalPrice { get; set; }//=> TransactionProducts.Sum(tp => ((tp.Quantity * tp.UnitPrice)* ((1 - (Discount / 100)))));// (1 - (Discount / 100)));
|
||||
public virtual IList<Report> Reports { get; set; } = new List<Report>();
|
||||
|
||||
public Transaction2()
|
||||
{
|
||||
|
@ -18,6 +18,12 @@ namespace FirmTracker_Server.nHibernate.Transactions
|
||||
.KeyColumn("TransactionId")
|
||||
.Cascade.AllDeleteOrphan()
|
||||
.Inverse(); // Ustawienie Inverse() wskazuje, że to `TransactionProduct` jest właścicielem relacji
|
||||
|
||||
HasManyToMany(x => x.Reports)
|
||||
.Cascade.All()
|
||||
.Table("ReportTransactions")
|
||||
.ParentKeyColumn("TransactionId")
|
||||
.ChildKeyColumn("ReportId");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,12 @@ namespace FirmTracker_Server.nHibernate.Transactions
|
||||
.KeyColumn("TransactionId")
|
||||
.Cascade.AllDeleteOrphan()
|
||||
.Inverse(); // Ustawienie Inverse() wskazuje, że to `TransactionProduct` jest właścicielem relacji
|
||||
|
||||
HasManyToMany(x => x.Reports)
|
||||
.Cascade.All()
|
||||
.Table("ReportTransactions")
|
||||
.ParentKeyColumn("TransactionId")
|
||||
.ChildKeyColumn("ReportId");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user