/// <summary>
 /// use for update command/query
 /// create list of key-value pair like [ propertyname = propertyvalue ,]  and so on
 /// dont consider primary key property in list
 /// </summary>
 /// <param name="mytype">type of class [ex person class or student etc]</param>
 private void SetUpdatePropertise(MyType myType)
 {
     try
     {
         UpdatePropertiesNamesValuesPair = "";
         SetPimaryKeyName(myType);
         foreach (PropertyInfo property in myType.GetType().GetProperties())
         {
             if (property.Name != PrimaryKeyNameInSourceCode && !AttributeHeler.CheckIgnoreColumn(property))
             {
                 TypeCode typeCode = Type.GetTypeCode(property.PropertyType);
                 string   Name     = AttributeHeler.GetColumnName(property);// property.Name;
                 Object   value    = property.GetValue(myType, null);
                 if (Name != PrimaryKeyNameInDB)
                 {
                     UpdatePropertiesNamesValuesPair += (Name + "='" + value + "',");
                 }
             }
         }
         UpdatePropertiesNamesValuesPair = UpdatePropertiesNamesValuesPair.Remove(UpdatePropertiesNamesValuesPair.Length - 1);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 /// <summary>
 /// check that the class has [primarykey] attribute or not
 /// if yes true
 /// else false
 /// </summary>
 /// <param name="mytype">datatype [ex employee class or student class etc]</param>
 /// <returns></returns>
 private bool ContainsPrimaryKey(MyType myType)
 {
     foreach (PropertyInfo property in myType.GetType().GetProperties())
     {
         if (AttributeHeler.IsPrimaryKeyAttribute(property))
         {
             return(true);
         }
     }
     return(false);
 }
        /// <summary>
        /// create comma separated list of property values
        /// if includeprimary is true then primary key value also consider in list
        /// else primary key value is remove from list
        /// </summary>
        /// <param name="mytype">type of class [ex person class or student etc]</param>
        /// <param name="includeprimary">weather primary key property should consider in list or not if yes : consider , if false : removed from list</param>
        private void SetPropertiesValues(MyType myType, bool includePrimary = true)
        {
            string CompleteVal = string.Empty;

            foreach (PropertyInfo property in myType.GetType().GetProperties())
            {
                if (!AttributeHeler.CheckIgnoreColumn(property) && includePrimary == AttributeHeler.IsPrimaryKeyAttribute(property))
                {
                    TypeCode typeCode = Type.GetTypeCode(property.PropertyType);
                    string   Name     = property.Name;
                    Object   value    = property.GetValue(myType, null);
                    var      val      = ClassHelper <MyType> .SetValue(Name, value, myType);

                    CompleteVal += (ClassHelper <MyType> .CreateSqlString(val) + ",");
                }
            }
            CompleteVal      = CompleteVal.Remove(CompleteVal.Length - 1);
            PropertiesValues = CompleteVal;
        }
 /// <summary>
 /// create comma separated propertyname list
 /// if includeprimary is true then primary key propery also consider in list
 /// else primary key property is remove from list
 /// </summary>
 /// <param name="mytype">type of class [ex person class or student etc]</param>
 /// <param name="includeprimary">weather primary key property should consider in list or not if yes : consider , if false : removed from list</param>
 private void SetPropertiesNames(MyType myType, bool includePrimary = true)
 {
     foreach (var property in myType.GetType().GetProperties())
     {
         if (!AttributeHeler.CheckIgnoreColumn(property))
         {
             if (includePrimary)
             {
                 string Name = AttributeHeler.GetColumnName(property);
                 PropertiesNames += (Name + ",");
             }
             else if (!AttributeHeler.IsPrimaryKeyAttribute(property))
             {
                 string Name = AttributeHeler.GetColumnName(property);
                 PropertiesNames += (Name + ",");
             }
         }
     }
     PropertiesNames = PropertiesNames.Remove(PropertiesNames.Length - 1);
 }
        /// <summary>
        /// Helper method
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="dr"></param>
        /// <returns></returns>
        private static T GetItem <T>(DataRow dr)
        {
            Type temp = typeof(T);
            T    obj  = Activator.CreateInstance <T>();

            foreach (DataColumn column in dr.Table.Columns)
            {
                foreach (PropertyInfo pro in temp.GetProperties())
                {
                    string primaryKeyName = AttributeHeler.GetColumnName(pro);
                    if (primaryKeyName == column.ColumnName && dr[column.ColumnName] != DBNull.Value)
                    {
                        pro.SetValue(obj, dr[column.ColumnName], null);
                    }
                    else
                    {
                        continue;
                    }
                }
            }
            return(obj);
        }
        /// <summary>
        /// return primary key name
        /// </summary>
        /// <param name="mytype"></param>
        /// <returns></returns>
        private string SetPimaryKeyName(MyType myType)
        {
            var isContainsPrimarKey = ContainsPrimaryKey(myType);

            if (isContainsPrimarKey)
            {
                //foreach loop can be optimised
                foreach (PropertyInfo property in myType.GetType().GetProperties())
                {
                    if (AttributeHeler.IsPrimaryKeyAttribute(property))
                    {
                        PrimaryKeyNameInSourceCode = property.Name;
                        string primaryKeyName = AttributeHeler.GetColumnName(property);
                        PrimaryKeyNameInDB = primaryKeyName;
                        return(primaryKeyName);
                    }
                }
            }
            else
            {
                throw new Exception(ExceptionMessage.PK_NOT_EXIST);
            }
            throw new Exception("Error occured in SetPkName function");
        }