title: Dynamics Crm Data validation for ssis packages
body: <p>I am currently importing data from a flat file to a CRM database using C# script component in ssis package.
  Now, I need to do data validation for the data like:</p>
  
  <ol>
  <li>To check whether the attribute is required field in crm  </li>
  <li>To check whether the attribute is taking correct datatype  </li>
  <li>To check the length and max,Min size of the Text type Attribute  </li>
  <li>To check lookup and picklist type attributes were referring to correct schema  </li>
  </ol>
  
  <p>All this I need them to be validated in ssis script component using C# code.
  I'm very new to such data validations.</p>
  
  <p>I tried to do data validation using data conversion transformation and data profiling task and later came to know that is not the exact way to do it and it should be in c# code.</p>
  
  <p>I later tried validation like this:</p>
  
  <pre><code>while (string.IsNullOrEmpty(Row.AccountName))
  {
      MessageBox.Show("Account Name should not be Blank");
      if (!string.IsNullOrEmpty(Row.AccountName))
      {
          break;
      }
  }
  
  if (!string.IsNullOrEmpty(Row.AccountName))
  {
      if (Row.AccountName.Length &lt;= 20)
          newaccount["name"] = Row.AccountName;
  
      while (Row.AccountName.Length &gt;= 20)
      {
          MessageBox.Show("Account name is too long and it should be less than 251 characters");
          if (Row.AccountName.Length &lt;= 20)
              newaccount["name"] = Row.AccountName;
          }
      }
  }
  </code></pre>
  
  <p>But I need to access the length and other properties from CRM metadata. Please advise.</p>