Пример #1
0
        protected List <String> GetConstrainingAttributes(String op)
        {
            List <string> list = new List <string>();

            PropertyInfo[] properties = data.GetType().GetProperties();
            foreach (PropertyInfo property in properties)
            {
                ColumnAttribute attribute =
                    (ColumnAttribute)Attribute.GetCustomAttribute(property, typeof(ColumnAttribute));


                if (attribute != null)
                {
                    MethodInfo method = property.GetGetMethod();
                    Object     ret    = method.Invoke(data, null);
                    SqlConvert(ref ret);
                    if (data.ContainsConstrainingAttribute(QueryStrategyConfiguration.PRIMARYKEY) && attribute is IPrimaryKeyAttribute)
                    {
                        StringBuilder tmp   = new StringBuilder().Append(AttributeUtilities.GetColumnMapping(property));
                        string        equal = " " + op + " ";
                        if (ret.ToString().Equals("NULL"))
                        {
                            equal = " IS ";
                        }

                        tmp.Append(equal).Append(ret.ToString());
                        list.Add(tmp.ToString());
                    }
                    else if (
                        data.ContainsConstrainingAttribute(property.Name) ||
                        data.ContainsConstrainingAttribute(AttributeUtilities.GetColumnMapping(property))
                        )
                    {
                        StringBuilder tmp   = new StringBuilder().Append(AttributeUtilities.GetColumnMapping(property));
                        string        equal = " " + op + " ";
                        if (ret.ToString().Equals("NULL"))
                        {
                            equal = " IS ";
                        }

                        tmp.Append(equal).Append(ret.ToString());
                        list.Add(tmp.ToString());
                    }
                }
            }
            return(list);
        }