예제 #1
0
 public virtual void UiBtnCommandAllFromPrimaryAction(Object param)
 {
     PrimaryKeyProperties.Clear();
     PrimaryKeyPropertiesIndex = -1;
 }
        public void OnEntityNonScalarPropertiesIndexChanged()
        {
            _RefreshCanExecute      = false;
            masterCodeClassFullName = "";
            PrimaryKeyProperties.Clear();
            PrincipalNonScalarProperties.Clear();
            PrincipalNonScalarPropertiesIndex = -1;


            if (EntityNonScalarPropertiesIndex < 0)
            {
                return;
            }
            if (EntityNonScalarProperties.Count <= EntityNonScalarPropertiesIndex)
            {
                return;
            }
            string navigationName = EntityNonScalarProperties[EntityNonScalarPropertiesIndex];

            _RefreshCanExecute = true;

            if (SelectedEntity == null)
            {
                return;
            }
            if (SelectedEntity.CodeElementRef == null)
            {
                return;
            }
            CodeClass    currentCodeClass = (SelectedEntity.CodeElementRef as CodeClass);
            CodeProperty codeProperty     = currentCodeClass.GetPublicMappedNonScalarPropertyByName(navigationName);

            if (codeProperty == null)
            {
                return;
            }
            CodeClass masterCodeClass = codeProperty.Type.CodeType as CodeClass;

            if (masterCodeClass == null)
            {
                return;
            }
            masterCodeClassFullName = masterCodeClass.Name;

            CodeClass dbContext = null;

            if (SelectedDbContext != null)
            {
                if (SelectedDbContext.CodeElementRef != null)
                {
                    dbContext = SelectedDbContext.CodeElementRef as CodeClass;
                }
            }
            FluentAPIKey primKey = new FluentAPIKey();

            masterCodeClass.CollectPrimaryKeyPropsHelper(primKey, dbContext);
            if (primKey.KeyProperties != null)
            {
                int order = 0;
                primKey.KeyProperties.ForEach(i => i.PropOrder = order++);
                masterCodeClass.CollectCodeClassAllMappedScalarProperties(PrimaryKeyProperties, primKey.KeyProperties);
            }
            List <CodeProperty> masterNavigations =
                masterCodeClass.GetPublicMappedNonScalarPropertiesByTypeFullName(currentCodeClass.FullName);

            if (masterNavigations == null)
            {
                return;
            }
            foreach (CodeProperty masterNavigation in masterNavigations)
            {
                PrincipalNonScalarProperties.Add(new FluentAPINavigationProperty()
                {
                    PropName           = masterNavigation.Name,
                    UnderlyingTypeName = currentCodeClass.FullName,
                    FullTypeName       = masterNavigation.Type.AsFullName,
                    IsCollection       = masterNavigation.IsOfCollectionType()
                });
            }
            DoRefresh();
        }