Created
July 15, 2015 21:36
-
-
Save hurricanepkt/be6bdc1bab032cf6e158 to your computer and use it in GitHub Desktop.
HowToSetup Mapping
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static tbl_Loss ToTblLoss(ImportLoss importLoss) | |
{ | |
var retVal = new tbl_Loss { | |
dat_dateOfClaim = importLoss.DateOfLoss, | |
txt_claimant = importLoss.Claimant, | |
lok_policy = _helper.FindPolicyFromPolicyNumber(impotLoss.PolicyNumber).aut_id, | |
}; | |
return retVal; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HelperClass // Rename me | |
{ | |
private Dictionary<string,tbl_Policy> PolicyCache = new Dictionary<string,tbl_Policy>(); | |
private Dictionary<string,tbl_Client> ClientCache = new Dictionary<string,tbl_Client>(); | |
public tbl_Policy FindPolicyFromPolicyNumber(string policyNumber) | |
{ | |
if (PolicyCache.ContainsKey(policyNumber)) { | |
return PolicyCache[policyNumber]; | |
} | |
var pol = ctx.tbl_Policy.Include("tbl_Client").Single(f => f.txt_policyNumber == policyNumber); | |
PolicyCache.Add(policyNumber, pol); | |
ClientCache.Add(policyNumber, pol.tbl_Client); | |
return pol; | |
} | |
public tbl_Client FindPolicyFromPolicyNumber(string policyNumber) | |
{ | |
if (ClientCache.ContainsKey(policyNumber)) { | |
return ClientCache[policyNumber]; | |
} | |
var client = ctx.tbl_Client.Single(f => f.tbl_Policy.Any(g => g.txt_policyNumber == policyNumber)); | |
ClientCache.Add(policyNumber, client); | |
return client; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment