예제 #1
0
        internal override void Invoke(CommandProcessorContext cpc)
        {
            var viewModel = _property.GetRootViewModel();

            Debug.Assert(viewModel != null, "Unable to find root view model from property: " + _property.Name);

            if (viewModel != null)
            {
                var property = viewModel.ModelXRef.GetExisting(_property) as Property;
                Debug.Assert(property != null);
                var cmd = new SetKeyPropertyCommand(property, _property.EntityKey);
                CommandProcessor.InvokeSingleCommand(cpc, cmd);
            }
        }
예제 #2
0
 // the key scenario that this is wanting to cover is where ModelGen has included a discriminator
 // column in the inferred set of keys in TPH; this column won't be mapped and can't be part of the key
 private void UnsetUnmappedKeyColumnsFromViews()
 {
     foreach (var view in _views)
     {
         foreach (var column in view.ResolvableKeys)
         {
             var mappings = column.GetAntiDependenciesOfType <ScalarProperty>();
             if (mappings.Count == 0)
             {
                 var command = new SetKeyPropertyCommand(column, false);
                 CommandProcessor.InvokeSingleCommand(_cpc, command);
             }
         }
     }
 }
예제 #3
0
        private void PropagateKeyToStorageColumn(Property property, Property column)
        {
            var table = column.EntityType;

            if (table != null)
            {
                // if we are mapped to a view or a defining query then proceed with key checking
                var ses = table.EntitySet as StorageEntitySet;
                if (ses != null &&
                    (ses.DefiningQuery != null || ses.StoreSchemaGeneratorTypeIsView))
                {
                    // cache this view off to process later
                    if (!_views.Contains(table))
                    {
                        _views.Add(table);
                    }

                    bool?setKey = null;

                    if (property.IsKeyProperty)
                    {
                        // this column should be a key
                        if (!column.IsKeyProperty)
                        {
                            setKey = true;
                        }
                    }
                    else
                    {
                        // this column should not be a key
                        if (column.IsKeyProperty)
                        {
                            setKey = false;
                        }
                    }

                    if (setKey != null)
                    {
                        var command = new SetKeyPropertyCommand(column, (bool)setKey);
                        CommandProcessor.InvokeSingleCommand(_cpc, command);
                    }
                }
            }
        }