コード例 #1
0
        public static bool CompareTo(this object obj, SearchModel fillterObj)
        {
            try
            {
                var fillterProperties = fillterObj.GetFillterProperties();
                var objProperties     = obj.GetType().GetProperties();
                foreach (var fillterProp in fillterProperties)
                {
                    var fillterValue = fillterProp.GetValue(fillterObj, null);
                    foreach (var objProp in objProperties)
                    {
                        if (objProp.Name.Equals(fillterProp.Name))
                        {
                            var objValue = objProp.GetValue(obj, null);
                            if (!objValue.Equals(fillterValue))
                            {
                                return(false);
                            }
                        }
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }