示例#1
0
        private CriteriaOperatorCollection GetOperatorCollection(string fields, DataTable dataTable)
        {
            var operatorCollection = new CriteriaOperatorCollection();

            foreach (string property in fields.Split(';'))
            {
                if (property != "" && property.IndexOf("!") == -1 && property != "This")
                {
                    XPMemberInfo xpMemberInfo = ReflectorHelper.GetXpMemberInfo(Session, ObjectType, property);
                    if (xpMemberInfo.IsPersistent)
                    {
                        operatorCollection.Add(CriteriaOperator.Parse(property, new object[0]));
                        var dataColumn = new DataColumn(property)
                        {
                            DataType = xpMemberInfo.MemberType
                        };
                        if (typeof(XPBaseObject).IsAssignableFrom(dataColumn.DataType))
                        {
                            dataColumn.DataType = Session.GetClassInfo(dataColumn.DataType).KeyProperty.MemberType;
                        }
                        dataTable.Columns.Add(dataColumn);
                        if (property == ObjectClassInfo.KeyProperty.Name)
                        {
                            dataTable.PrimaryKey = new[] { dataColumn }
                        }
                        ;
                    }
                }
            }
            return(operatorCollection);
        }