Exemplo n.º 1
0
        private void TranslateSelect()
        {
            //if SelectAll, get all property names
            if (SelectType == SelectTypeEnum.SelectAllAndUseAttachModel ||
                SelectType == SelectTypeEnum.SelectAllAndUseReplaceModel)
            {
                //if ReplaceModel and has selected, return
                if (SelectType == SelectTypeEnum.SelectAllAndUseReplaceModel &&
                    SelectByExpression.Any())
                {
                    return;
                }

                //if AttachModel or has not selected, add all properties
                foreach (var property in NamingConvention.GetAllPropertyNames(ElementType))
                {
                    if (SelectByExpression.Contains(property))
                    {
                        continue;
                    }
                    SelectByExpression.Add(property);
                }
            }

            if (SelectType == SelectTypeEnum.SelectIdAndUseAttachModel ||
                SelectType == SelectTypeEnum.SelectIdAndUseReplaceModel)
            {
                //if ReplaceModel and has selected, return
                if (SelectType == SelectTypeEnum.SelectIdAndUseReplaceModel &&
                    SelectByExpression.Any())
                {
                    return;
                }

                //if AttachModel or has not selected, add "id"
//                foreach (var property in ObjectNameProvider.GetAllPropertyNames(ElementType))
//                {
                if (!SelectByExpression.Contains("id", StringComparer.OrdinalIgnoreCase))
                {
                    SelectByExpression.Add("id");
                }
//                }
            }
        }