Created
May 28, 2018 00:53
-
-
Save jinan-kordab/cbdf9b3268b23901472eeff2ca85a849 to your computer and use it in GitHub Desktop.
Second business rule for semi identical records
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
var line = data[i].ToString().Split('\t'); | |
var nextLine = data[i + 1].ToString().Split('\t'); | |
if (line[0].ToString().Trim() == nextLine[0].ToString().Trim()) | |
{ | |
//The fourth column in our data text file that we already read - text file | |
String PKcriteria = nextLine[3].ToString().Trim(); | |
//ALL LRT3FK values, or , our Foreign Key Values Table | |
// We, in a way import all of it to our business layer, then use it | |
var allforeignkeyvaluesin_LRT3FK = (from fkey in LRT3FK | |
where fkey.COLFOUR == 4816 | |
select fkey).ToList(); | |
// Pick the one key that we need, since the two tables are related with constraints | |
var FKtoInsert = allforeignkeyvaluesin_LRT3FK.Where(x => x.COLTHREE.ToString().Trim() == PKcriteria.ToString().Trim()).Select(x => x.PKID).SingleOrDefault(); | |
DateTime nw = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0); | |
// Add row to data table | |
table.Rows.Add(new object[] { 4816, nextLine[0].ToString().Trim(), nw, Convert.ToByte(nextLine[4].ToString().Trim()), nextLine[1].ToString().Trim(), FKtoInsert }); | |
i = i + 1; | |
} | |
else | |
{ | |
//The fourth column in our data text file that we already read - text file | |
String PKcriteria = line[3].ToString().Trim(); | |
//ALL LRT3FK values, or , our Foreign Key Values Table | |
// We, in a way import all of it to our business layer, then use it | |
var allforeignkeyvaluesin_LRT3FK = (from fkey in LRT3FK | |
where fkey.COLFOUR == 4816 | |
select fkey).ToList(); | |
// Pick the one key that we need, since the two tables are related with constraints | |
var FKtoInsert = allforeignkeyvaluesin_LRT3FK.Where(x => x.COLTHREE.ToString().Trim() == PKcriteria.ToString().Trim()).Select(x => x.PKID).SingleOrDefault(); | |
DateTime nw = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0); | |
// Add row to data table | |
table.Rows.Add(new object[] { 4816, line[0].ToString().Trim(), nw, Convert.ToByte(line[4].ToString().Trim()), line[1].ToString().Trim(), FKtoInsert }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment