Remove Single Quote

   public static string RemoveSingleQuote(string data)
        {
            return string.IsNullOrEmpty(data) ? string.Empty : data.Replace("'", "''");
        }

 public static T RemoveSingleQuote<T>(object ob)
        {
            PropertyDescriptorCollection props =
                TypeDescriptor.GetProperties(typeof(T));

            T Tob = (T)ob;
            if (Tob != null)
            {
                for (int i = 0; i < props.Count; i++)
                {
                    PropertyDescriptor prop = props[i];
                    if (prop.PropertyType.Name == "String")
                    {
                        object oPropertyValue = prop.GetValue(Tob);
                        oPropertyValue = RemoveSingleQuote((string)oPropertyValue) as object;
                        oPropertyValue = RemoveSpace((string)oPropertyValue) as object;
                        prop.SetValue(Tob, oPropertyValue);
                    }
                    //oPropertyValue
                    //table.Columns.Add(prop.Name, prop.PropertyType);
                }
            }
            return Tob;
        }

Comments

Popular posts from this blog

Provision AWS EC2 Instance and RDS with Terraform, and Deploy Spring Boot App to EC2 Instance via GitHub Action Pipeline

JQuery UI Autocomplete, custom HTML structure for result?

Easy Ui Jquery easyui-textbox change onChange event