示例#1
0
        private List <Criteria> UpdateCriteria <T>(List <Criteria> criterias)
        {
            var found = ClassConfigContainer.FindClassConfig1 <T>();

            foreach (var criteria in criterias)
            {
                PropertyConfig propertyConfig = found.GetPropertyConfig(criteria.PropertyName);

                if (propertyConfig == null)
                {
                    var temp = criteria.PropertyName.Split(new[] { '.' }).ToList();

                    var propertyName = temp[temp.Count - 1];

                    temp.RemoveAt(temp.Count - 1);

                    var linkName = string.Join(".", temp);

                    var link = found.FindMatchedLink(linkName);


                    if (link != null)
                    {
                        var classConfig = ClassConfigContainer.FindClassConfig(link.RightType);

                        var propertyConfig1 = classConfig.GetPropertyConfig(propertyName);

                        if (propertyConfig1 == null)
                        {
                            throw new EasylinkException(
                                      "Error occurred when updating criteria. property name {0}  is not defined in the {1} mapping.",
                                      criteria.PropertyName, link.RightType.Name);
                        }

                        criteria.SetColumnName(string.Format("{0}.{1}", link.Alias, propertyConfig1.ColumnName));
                    }
                    else
                    {
                        throw new EasylinkException(
                                  "Error occurred when updating criteria. link name {0} is not defined in the {1} mapping.",
                                  linkName, typeof(T).Name);
                    }
                }
                else
                {
                    criteria.SetColumnName(propertyConfig.SelectColumn.Trim());
                }
            }

            return(criterias);
        }