onmyway365 .

onmyway365 .

  • NA
  • 39
  • 4.9k

Cases of type string in C#?

Jan 18 2016 3:37 AM
Hi all,
 
I am trying to create a data validation rule where the values are of the type string, and if the values do not match the given option, it updates the database field with the appropriate message:
 
Any suggestions on what I have below (or perhaps something else)? 
 
public static void Validate()
{
using (var stageContext = new StagingTableDataContext())
{
var data = stageContext.ProjectMasters;
foreach (var sourceDataEntry in data)
 
if (sourceDataEntry.Finance_Project_Region != "Gauteng") ||
(sourceDataEntry.Finance_Project_Region != "Free State") ||
(sourceDataEntry.Finance_Project_Region != "Limpopo") ||
(sourceDataEntry.Finance_Project_Region != "Kwazulu Natal") ||
(sourceDataEntry.Finance_Project_Region != "Western Cape");
{
sourceDataEntry.Processing_Result = 2;
sourceDataEntry.Processing_Result_Text = "Incorrect Province";
sourceDataEntry.Processed_Datetime = DateTime.Now;
         }
         stageContext.SubmitChanges(); 
    }
 
Thank you in advance! 

Answers (10)