Z
Zain Nabi
Guest
I do not have duplicate records in my database however in my view. It shows duplicates. ClientId is a Guid which is passed on to each table in the join.
Please help
public
Continue reading...
Please help
What I have tried:
public
ActionResult ClientInfo(
string ClientId)
{
var{
query = (
from x
in db.FinancialNeedsClients
join y
in db.FinancialSpouseDetailss on x.ClientId equals y.ClientId into ylist from y in ylist.DefaultIfEmpty()
join z
in db.FinancialSpouseDetailss on x.ClientId equals z.ClientId into zlist from z in zlist.DefaultIfEmpty()
join c
in db.FinancialNeedsChildrens on x.ClientId equals c.ClientId into clist from c in clist.DefaultIfEmpty()
join d
in db.FinancialNeedDependentss on x.ClientId equals d.ClientId into dlist from d in dlist.DefaultIfEmpty()
join e
in db.FinancialNeedContactDetailss on x.ClientId equals e.ClientId into elist from e in elist.DefaultIfEmpty()
where x.ClientId == ClientId
select new FinancialNeedClientInfoViewModel()
{
Id = x.Id,
ClientId = x.ClientId,
Surnname = x.Surnname,
FirstName = x.FirstName,
IDNumber = x.IDNumber,
DOB = x.DOB,
Age = (
int{
Id = x.Id,
ClientId = x.ClientId,
Surnname = x.Surnname,
FirstName = x.FirstName,
IDNumber = x.IDNumber,
DOB = x.DOB,
Age = (
?)x.Age ??
0,
Nationality = x.Nationality,
Occupation = x.Occupation,
TaxRef = x.TaxRef,
EmailAddress = x.EmailAddress,
ContactNumber = x.ContactNumber,
MaritaStatus = x.MaritaStatus,
MaritalRegime = x.MaritalRegime,
YearOfMarriage = x.YearOfMarriage,
IfOther = x.IfOther,
SpouseId = (
intNationality = x.Nationality,
Occupation = x.Occupation,
TaxRef = x.TaxRef,
EmailAddress = x.EmailAddress,
ContactNumber = x.ContactNumber,
MaritaStatus = x.MaritaStatus,
MaritalRegime = x.MaritalRegime,
YearOfMarriage = x.YearOfMarriage,
IfOther = x.IfOther,
SpouseId = (
?)y.Id ??
0,
SpouseSurnname = y.Surnname,
SpouseFirstName = y.FirstName,
SpouseIDNumber = y.IDNumber,
SpouseDOB = y.DOB,
SpouseAge = (
intSpouseSurnname = y.Surnname,
SpouseFirstName = y.FirstName,
SpouseIDNumber = y.IDNumber,
SpouseDOB = y.DOB,
SpouseAge = (
?)y.Age ??
0,
SpouseNationality = y.Nationality,
SpouseOccupation = y.Occupation,
SpouseTaxRef = y.TaxRef,
SpouseEmailAddress = y.EmailAddress,
SpouseContactNumber = y.ContactNumber,
ChildId = (
intSpouseNationality = y.Nationality,
SpouseOccupation = y.Occupation,
SpouseTaxRef = y.TaxRef,
SpouseEmailAddress = y.EmailAddress,
SpouseContactNumber = y.ContactNumber,
ChildId = (
?)c.Id ??
0,
ChildrenFIrst_Name = c.FIrst_Name,
ChildrenGender = c.Gender,
ChildrenAge = (
intChildrenFIrst_Name = c.FIrst_Name,
ChildrenGender = c.Gender,
ChildrenAge = (
?)c.Age ??
0,
ChildrenOccupation = c.Occupation,
ChildrenDOB = c.DOB,
DepId = (
intChildrenOccupation = c.Occupation,
ChildrenDOB = c.DOB,
DepId = (
?)d.Id ??
0,
DepdendentFIrst_Name = d.FIrst_Name,
DepdendentAge = (
intDepdendentFIrst_Name = d.FIrst_Name,
DepdendentAge = (
?)d.Age ??
0,
DepdendentRelationship = d.Relationship,
ContactId = (
intDepdendentRelationship = d.Relationship,
ContactId = (
?)e.Id ??
0,
MainMemberResedentialAddress = e.ResedentialAddress,
MainMemberPostalAddress = e.PostalAddress,
MainMemberBusinessAddress = e.BusinessAddress,
MainMemberMobileNumber = e.MobileNumber
}).Distinct().ToList();
MainMemberResedentialAddress = e.ResedentialAddress,
MainMemberPostalAddress = e.PostalAddress,
MainMemberBusinessAddress = e.BusinessAddress,
MainMemberMobileNumber = e.MobileNumber
}).Distinct().ToList();
Continue reading...