public static EdmProperty IncludeColumn(
            EntityType table, EdmProperty templateColumn, Func <EdmProperty, bool> isCompatible, bool useExisting)
        {
            DebugCheck.NotNull(table);
            DebugCheck.NotNull(templateColumn);

            var existingColumn = table.Properties.FirstOrDefault(isCompatible);

            if (existingColumn == null)
            {
                templateColumn = templateColumn.Clone();
            }
            else if (!useExisting &&
                     !existingColumn.IsPrimaryKeyColumn)
            {
                templateColumn = templateColumn.Clone();
            }
            else
            {
                templateColumn = existingColumn;
            }

            AddColumn(table, templateColumn);

            return(templateColumn);
        }
        public static EdmProperty IncludeColumn(
            EntityType table, EdmProperty templateColumn, bool useExisting)
        {
            DebugCheck.NotNull(table);
            DebugCheck.NotNull(templateColumn);

            var existingColumn =
                table.Properties.SingleOrDefault(c => string.Equals(c.Name, templateColumn.Name, StringComparison.Ordinal));

            if (existingColumn == null)
            {
                templateColumn = templateColumn.Clone();
            }
            else if (!useExisting &&
                     !existingColumn.IsPrimaryKeyColumn)
            {
                templateColumn = templateColumn.Clone();
            }
            else
            {
                templateColumn = existingColumn;
            }

            AddColumn(table, templateColumn);

            return(templateColumn);
        }
Example #3
0
        public static EdmProperty IncludeColumn(
            EntityType table,
            EdmProperty templateColumn,
            Func <EdmProperty, bool> isCompatible,
            bool useExisting)
        {
            EdmProperty edmProperty = table.Properties.FirstOrDefault <EdmProperty>(isCompatible);

            templateColumn = edmProperty != null ? (useExisting || edmProperty.IsPrimaryKeyColumn ? edmProperty : templateColumn.Clone()) : templateColumn.Clone();
            TablePrimitiveOperations.AddColumn(table, templateColumn);
            return(templateColumn);
        }