本文整理汇总了C#中Set.MakeReadOnly方法的典型用法代码示例。如果您正苦于以下问题:C# Set.MakeReadOnly方法的具体用法?C# Set.MakeReadOnly怎么用?C# Set.MakeReadOnly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Set
的用法示例。
在下文中一共展示了Set.MakeReadOnly方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FixSet
static private void FixSet(ref Set<AssociationEndMember> set)
{
if (null == set)
{
set = Set<AssociationEndMember>.Empty;
}
else
{
set.MakeReadOnly();
}
}
示例2: EntityCommandDefinition
/// <summary>
/// don't let this be constructed publicly;
/// </summary>
/// <exception cref="EntityCommandCompilationException">Cannot prepare the command definition for execution; consult the InnerException for more information.</exception>
/// <exception cref="NotSupportedException">The ADO.NET Data Provider you are using does not support CommandTrees.</exception>
internal EntityCommandDefinition(DbProviderFactory storeProviderFactory, DbCommandTree commandTree) {
EntityUtil.CheckArgumentNull(storeProviderFactory, "storeProviderFactory");
EntityUtil.CheckArgumentNull(commandTree, "commandTree");
DbProviderServices storeProviderServices = DbProviderServices.GetProviderServices(storeProviderFactory);
try {
if (DbCommandTreeKind.Query == commandTree.CommandTreeKind) {
// Next compile the plan for the command tree
List<ProviderCommandInfo> mappedCommandList = new List<ProviderCommandInfo>();
ColumnMap columnMap;
int columnCount;
PlanCompiler.Compile(commandTree, out mappedCommandList, out columnMap, out columnCount, out _entitySets);
_columnMapGenerators = new IColumnMapGenerator[] {new ConstantColumnMapGenerator(columnMap, columnCount)};
// Note: we presume that the first item in the ProviderCommandInfo is the root node;
Debug.Assert(mappedCommandList.Count > 0, "empty providerCommandInfo collection and no exception?"); // this shouldn't ever happen.
// Then, generate the store commands from the resulting command tree(s)
_mappedCommandDefinitions = new List<DbCommandDefinition>(mappedCommandList.Count);
foreach (ProviderCommandInfo providerCommandInfo in mappedCommandList) {
DbCommandDefinition providerCommandDefinition = storeProviderServices.CreateCommandDefinition(providerCommandInfo.CommandTree);
if (null == providerCommandDefinition) {
throw EntityUtil.ProviderIncompatible(System.Data.Entity.Strings.ProviderReturnedNullForCreateCommandDefinition);
}
_mappedCommandDefinitions.Add(providerCommandDefinition);
}
}
else {
Debug.Assert(DbCommandTreeKind.Function == commandTree.CommandTreeKind, "only query and function command trees are supported");
DbFunctionCommandTree entityCommandTree = (DbFunctionCommandTree)commandTree;
// Retrieve mapping and metadata information for the function import.
FunctionImportMappingNonComposable mapping = GetTargetFunctionMapping(entityCommandTree);
IList<FunctionParameter> returnParameters = entityCommandTree.EdmFunction.ReturnParameters;
int resultSetCount = returnParameters.Count > 1 ? returnParameters.Count : 1;
_columnMapGenerators = new IColumnMapGenerator[resultSetCount];
TypeUsage storeResultType = DetermineStoreResultType(entityCommandTree.MetadataWorkspace, mapping, 0, out _columnMapGenerators[0]);
for (int i = 1; i < resultSetCount; i++)
{
DetermineStoreResultType(entityCommandTree.MetadataWorkspace, mapping, i, out _columnMapGenerators[i]);
}
// Copy over parameters (this happens through a more indirect route in the plan compiler, but
// it happens nonetheless)
List<KeyValuePair<string, TypeUsage>> providerParameters = new List<KeyValuePair<string, TypeUsage>>();
foreach (KeyValuePair<string, TypeUsage> parameter in entityCommandTree.Parameters)
{
providerParameters.Add(parameter);
}
// Construct store command tree usage.
DbFunctionCommandTree providerCommandTree = new DbFunctionCommandTree(entityCommandTree.MetadataWorkspace, DataSpace.SSpace,
mapping.TargetFunction, storeResultType, providerParameters);
DbCommandDefinition storeCommandDefinition = storeProviderServices.CreateCommandDefinition(providerCommandTree);
_mappedCommandDefinitions = new List<DbCommandDefinition>(1) { storeCommandDefinition };
EntitySet firstResultEntitySet = mapping.FunctionImport.EntitySets.FirstOrDefault();
if (firstResultEntitySet != null)
{
_entitySets = new Set<EntitySet>();
_entitySets.Add(mapping.FunctionImport.EntitySets.FirstOrDefault());
_entitySets.MakeReadOnly();
}
}
// Finally, build a list of the parameters that the resulting command should have;
List<EntityParameter> parameterList = new List<EntityParameter>();
foreach (KeyValuePair<string, TypeUsage> queryParameter in commandTree.Parameters) {
EntityParameter parameter = CreateEntityParameterFromQueryParameter(queryParameter);
parameterList.Add(parameter);
}
_parameters = new System.Collections.ObjectModel.ReadOnlyCollection<EntityParameter>(parameterList);
}
catch (EntityCommandCompilationException) {
// No need to re-wrap EntityCommandCompilationException
throw;
}
catch (Exception e) {
// we should not be wrapping all exceptions
if (EntityUtil.IsCatchableExceptionType(e)) {
// we don't wan't folks to have to know all the various types of exceptions that can
// occur, so we just rethrow a CommandDefinitionException and make whatever we caught
// the inner exception of it.
throw EntityUtil.CommandCompilation(System.Data.Entity.Strings.EntityClient_CommandDefinitionPreparationFailed, e);
}
throw;
}
}