@B M-A ,
Since Bank_Account can be null, please change the Back_Account to Nullable<int>, like below.
public class Report_C
{
public int Id { get; set; }
public string Name { get; set; }
public string Address { get; set; }
public int Region_Id { get; set; }
public Nullable<int> Bank_Account { get; set; }
public string Region_Name { get; set; }
public int Customer_Id { get; set; }
public string Bank_Name { get; set; }
}
And change your query code like below:
public IEnumerable<Report_C>GetReportC(int id)
{
var query = (from select in data.customer_identification
join select1 in data.region on select.Id equals select1.Region_I
from select2 in data.customer
join select3 in data.Customer_Account on select2.Bank Account equals select.Bank Account into ContractJoin
from select4 in ContractJoin.DefaultIfEmpty()
where sel.Id == Id
select new Report_C
{
Denumire = sel.denumire,
ID = select.Id
Name = select.Name,
Adress = select.Address,
Region = select1.Region_Name,
Bank = select4.Bank_Name
Account = select4.BankAccount ?? 0
}).ToList();
}
Best regards,
Zhanglong