本文整理汇总了C#中System.Xml.Linq.XDocument.HasSystemOperations方法的典型用法代码示例。如果您正苦于以下问题:C# XDocument.HasSystemOperations方法的具体用法?C# XDocument.HasSystemOperations怎么用?C# XDocument.HasSystemOperations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Linq.XDocument
的用法示例。
在下文中一共展示了XDocument.HasSystemOperations方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HasSystemOperations_should_return_true_when_any_element_has_is_system_attribute
public void HasSystemOperations_should_return_true_when_any_element_has_is_system_attribute()
{
var xdocument = new XDocument(new XElement("foo", new XAttribute(EdmXNames.IsSystem, "true")));
Assert.True(xdocument.HasSystemOperations());
}
示例2: Diff
public IEnumerable<MigrationOperation> Diff(XDocument sourceModel, XDocument targetModel, bool? includeSystemOperations = null)
{
DbProviderInfo providerInfo;
_source
= new ModelMetadata
{
Model = sourceModel,
StoreItemCollection = sourceModel.GetStoreItemCollection(out providerInfo),
ProviderManifest = GetProviderManifest(providerInfo),
ProviderInfo = providerInfo
};
_target
= new ModelMetadata
{
Model = targetModel,
StoreItemCollection = targetModel.GetStoreItemCollection(out providerInfo),
ProviderManifest = GetProviderManifest(providerInfo),
ProviderInfo = providerInfo
};
_consistentProviders
= _source.ProviderInfo.ProviderInvariantName.EqualsIgnoreCase(
_target.ProviderInfo.ProviderInvariantName)
&& _source.ProviderInfo.ProviderManifestToken.EqualsIgnoreCase(
_target.ProviderInfo.ProviderManifestToken);
var renamedColumns = FindRenamedColumns().ToList();
var addedColumns = FindAddedColumns(renamedColumns).ToList();
var alteredColumns = FindChangedColumns().ToList();
var removedColumns = FindRemovedColumns(renamedColumns).ToList();
var renamedTables = FindRenamedTables().ToList();
var movedTables = FindMovedTables().ToList();
var addedTables = FindAddedTables(renamedTables).ToList();
var columnNormalizedSourceModel = BuildColumnNormalizedSourceModel(renamedColumns);
var addedForeignKeys = FindAddedForeignKeys(columnNormalizedSourceModel).ToList();
var removedTables = FindRemovedTables(renamedTables).ToList();
var removedForeignKeys = FindRemovedForeignKeys(columnNormalizedSourceModel).ToList();
var changedPrimaryKeys = FindChangedPrimaryKeys(columnNormalizedSourceModel).ToList();
if (includeSystemOperations == null)
{
includeSystemOperations
= sourceModel.HasSystemOperations() && targetModel.HasSystemOperations();
}
return renamedTables
.Concat<MigrationOperation>(movedTables)
.Concat(removedForeignKeys)
.Concat(removedForeignKeys.Select(fko => fko.CreateDropIndexOperation()))
.Concat(renamedColumns)
.Concat(addedTables)
.Concat(addedColumns)
.Concat(alteredColumns)
.Concat(changedPrimaryKeys)
.Concat(addedForeignKeys)
.Concat(addedForeignKeys.Select(fko => fko.CreateCreateIndexOperation()))
.Concat(removedColumns)
.Concat(removedTables)
.Where(o => (includeSystemOperations == true) || !o.IsSystem)
.ToList();
}
示例3: RevertMigration
internal override void RevertMigration(string migrationId, DbMigration migration, XDocument sourceModel, XDocument targetModel)
{
bool? includeSystemOps = null;
if (ReferenceEquals(targetModel, _emptyModel.Value))
{
includeSystemOps = true;
if (!sourceModel.HasSystemOperations())
{
// upgrade scenario, inject the history model
_historyRepository
.AppendHistoryModel(
sourceModel,
new DbProviderInfo(_usersContextInfo.ConnectionProviderName, _providerManifestToken));
}
}
var systemOperations
= _modelDiffer.Diff(sourceModel, targetModel, includeSystemOps)
.Where(o => o.IsSystem);
migration.Down();
ExecuteOperations(migrationId, targetModel, migration.Operations.Concat(systemOperations), downgrading: true);
}
示例4: RevertMigration
internal override void RevertMigration(string migrationId, DbMigration migration, XDocument sourceModel, XDocument targetModel)
{
bool? includeSystemOps = null;
if (ReferenceEquals(targetModel, _emptyModel.Value)
&& !_historyRepository.IsShared())
{
includeSystemOps = true;
if (!sourceModel.HasSystemOperations())
{
// upgrade scenario, inject the history model
AttachHistoryModel(sourceModel);
}
}
var systemOperations
= _modelDiffer.Diff(sourceModel, targetModel, includeSystemOps)
.Where(o => o.IsSystem);
migration.Down();
ExecuteOperations(migrationId, targetModel, migration.Operations.Concat(systemOperations), downgrading: true);
}