Reputation: 468
I have 2 classes:
[Table(Name = "_Reference2")]
public class Customer
{
[Column(Name = "_IDRRef")]
public Binary CustomerRef { get; set; }
[Column(Name = "_Description")]
public string Name { get; set; }
}
[Table(Name = "_AccumReg2210")]
public class Payment
{
[Column(Name="_Period")]
public DateTime Period { get; set; }
[Column(Name = "_Fld2211RRef")]
public Binary Customer { get; set; }
[Column(Name = "_Fld5051RRef")]
public decimal Sum { get; set; }
}
Is there any opportunity to combine this classes in 1 class? Usually, I need to write query witn JOIN (ON Customer.CustomerRef = Payment.Customer) to this classes. It will be better to implement complex class, connected to both tables.
Upvotes: 0
Views: 1346
Reputation: 13350
I'm not sure if this applies to your needed solution, but have you considered a simple CustomerPaymentViewModel class?
public class CustomerPaymentViewModel
{
public Customer { get; set; }
public Payment { get; set; }
}
Upvotes: 0
Reputation: 589
If you don't want to join explicitly the two tables using Linq, you could create a View in your database and generate a model with it (using LinqToSQL or Entities Framework) ?
Upvotes: 0
Reputation: 33149
var results = from c in Customers
from p in Payments
where p.Customer == c.CustomerRef
select new ComplexObject() {
Name = c.Name,
...
};
Upvotes: 2