本文整理汇总了C#中EntityMetadata类的典型用法代码示例。如果您正苦于以下问题:C# EntityMetadata类的具体用法?C# EntityMetadata怎么用?C# EntityMetadata使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EntityMetadata类属于命名空间,在下文中一共展示了EntityMetadata类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EntityExtractor
public EntityExtractor(string entityName, List<EnviromentValue> enviromentValues, EntityMetadata entityDefine)
{
_entityDefine = entityDefine;
EntityName = entityName;
_enviromentValues = enviromentValues;
}
示例2: SqlServerGenerator
public SqlServerGenerator(Type entityType)
{
var metadata = new EntityMetadata(entityType);
IsIdentity = metadata.FirstOrDefault(x => x.IsIdentity) != null;
var selectFields = string.Join(", ", metadata.Select(i => $"{i.DbName} AS {i.Name}"));
var insertFields = string.Join(", ", metadata.Where(i => !i.IsIdentity).Select(i => i.DbName));
var insertValues = string.Join(", ", metadata.Where(i => !i.IsIdentity).Select(i => $"@{i.Name}"));
var updatePairs = string.Join(", ", metadata.Where(i => !i.IsPrimaryKey).Select(i => $"{i.DbName} = @{i.Name}"));
var whereCondition = string.Join(" AND ", metadata.Where(i => i.IsPrimaryKey).Select(i => $"{i.DbName} = @{i.Name}"));
SelectAllSql = $"SELECT {selectFields} FROM {metadata.DbName}";
SelectSql = SelectAllSql;
if (whereCondition.Length > 0)
SelectSql += $" WHERE {whereCondition}";
InsertSql = $"INSERT INTO {metadata.DbName} ({insertFields}) VALUES ({insertValues})";
if (IsIdentity)
{
InsertSql += Environment.NewLine;
InsertSql += "SELECT SCOPE_IDENTITY()";
}
UpdateSql = $"UPDATE {metadata.DbName} SET {updatePairs}";
if (whereCondition.Length > 0)
UpdateSql += $" WHERE {whereCondition}";
DeleteAllSql = $"DELETE FROM {metadata.DbName}";
DeleteSql = DeleteAllSql;
if (whereCondition.Length > 0)
DeleteSql += $" WHERE {whereCondition}";
CountSql = $"SELECT COUNT(1) FROM {metadata.DbName}";
}
示例3: BuildCodeTypeReferenceForPartyList
CodeTypeReference ITypeMappingService.GetTypeForAttributeType(EntityMetadata entityMetadata, AttributeMetadata attributeMetadata, IServiceProvider services)
{
var type = typeof (object);
if (attributeMetadata.AttributeType.HasValue)
{
var key = attributeMetadata.AttributeType.Value;
if (_attributeTypeMapping.ContainsKey(key))
{
type = _attributeTypeMapping[key];
}
else
{
if (key == AttributeTypeCode.PartyList)
{
return BuildCodeTypeReferenceForPartyList(services);
}
var attributeOptionSet = GetAttributeOptionSet(attributeMetadata);
if (attributeOptionSet != null)
{
return BuildCodeTypeReferenceForOptionSet(attributeMetadata.LogicalName, entityMetadata, attributeOptionSet, services);
}
}
if (type.IsValueType)
{
type = typeof (Nullable<>).MakeGenericType(new[] {type});
}
}
return TypeRef(type);
}
示例4: AttributePicker
public AttributePicker(EntityMetadata emd, IEnumerable<string> alreadySelectedAttributes, IOrganizationService service)
{
this.emd = emd;
this.alreadySelectedAttributes = alreadySelectedAttributes;
this.service = service;
InitializeComponent();
}
示例5: AddEntityAttributesToList
private void AddEntityAttributesToList(EntityMetadata emd)
{
lvAttributes.Items.Clear();
foreach (AttributeMetadata amd in emd.Attributes.Where(a => a.IsAuditEnabled != null
&& a.IsAuditEnabled.Value
&& a.AttributeOf == null))
{
var attributeInfo = attributeInfos.FirstOrDefault(a => a.Amd == amd);
if (attributeInfo == null)
{
attributeInfos.Add(new AttributeInfo {Action = ActionState.None, InitialState = true, Amd = amd});
}
else if (attributeInfo.Action == ActionState.Removed)
{
continue;
}
string displayName = amd.DisplayName != null && amd.DisplayName.UserLocalizedLabel != null
? amd.DisplayName.UserLocalizedLabel.Label
: "N/A";
var itemAttr = new ListViewItem {Text = displayName, Tag = amd };
itemAttr.SubItems.Add(amd.LogicalName);
lvAttributes.Items.Add(itemAttr);
}
}
示例6: AppendGetAutoincrementField
protected override void AppendGetAutoincrementField(StringBuilder commandText, EntityMetadata entityMetadata)
{
commandText.Append("\nRETURNING ")
.Append(DataService.EntityLiteProvider.StartQuote)
.Append(entityMetadata.Properties[entityMetadata.AutogeneratedFieldName].SqlField.BaseColumnName)
.Append(DataService.EntityLiteProvider.EndQuote).Append(";");
}
示例7: GetSyncRecordId
private static object GetSyncRecordId(object id, EntityMetadata metadata, Dictionary<string, object> syncParams)
{
if (!metadata.Attributes.Any(c =>syncParams.ContainsKey(c.PropertyName)))
{
return id;
}
var oldItem = DynamicRepository.Get(metadata, FilterCriteriaSet.And.Equal(id, metadata.PrimaryKeyPropertyName), ExternalMethodsCallMode.None).FirstOrDefault();
foreach(var p in syncParams)
{
if(metadata.Attributes.Any(c => c.PropertyName == p.Key))
{
if ((oldItem as DynamicEntity)[p.Key].Equals(p.Value))
return id;
}
}
FilterCriteriaSet compareFilter = FilterCriteriaSet.And;
foreach (var p in syncParams)
{
if (metadata.Attributes.Any(c => c.PropertyName == p.Key))
{
compareFilter.Merge(FilterCriteriaSet.And.Equal(p.Value, p.Key));
}
}
foreach (var attributeToCompare in metadata.Attributes.Where(a => a.ForCompare))
{
compareFilter.Merge(FilterCriteriaSet.And.Equal((oldItem as DynamicEntity)[attributeToCompare.PropertyName], attributeToCompare.PropertyName));
}
var item = DynamicRepository.Get(metadata, compareFilter, ExternalMethodsCallMode.None).FirstOrDefault();
return item != null ? (item as DynamicEntity).GetId() : id;
}
示例8: AddEntityAttributesToList
private void AddEntityAttributesToList(EntityMetadata emd)
{
string groupName = string.Format("{0} ({1})",
emd.DisplayName.UserLocalizedLabel.Label,
emd.LogicalName);
var group = new ListViewGroup {Header = groupName, Name = groupName};
lvAttributes.Groups.Add(@group);
foreach (AttributeMetadata amd in emd.Attributes.Where(a => a.IsAuditEnabled != null
&& a.IsAuditEnabled.Value
&& a.AttributeOf == null))
{
attributeInfos.Add(new AttributeInfo {Action = ActionState.None, InitialState = true, Amd = amd});
string displayName = amd.DisplayName != null && amd.DisplayName.UserLocalizedLabel != null
? amd.DisplayName.UserLocalizedLabel.Label
: "N/A";
var itemAttr = new ListViewItem {Text = displayName, Tag = amd, Group = @group};
itemAttr.SubItems.Add(amd.LogicalName);
lvAttributes.Items.Add(itemAttr);
}
}
示例9: GetNameForOptionSet
/// <summary>
/// Provide a new implementation for finding a name for an OptionSet. If the
/// OptionSet is not global, we want the name to be the concatenation of the Entity's
/// name and the Attribute's name. Otherwise, we can use the default implementation.
/// </summary>
public String GetNameForOptionSet(
EntityMetadata entityMetadata, OptionSetMetadataBase optionSetMetadata,
IServiceProvider services)
{
// Ensure that the OptionSet is not global before using the custom
// implementation.
if (optionSetMetadata.IsGlobal.HasValue && !optionSetMetadata.IsGlobal.Value)
{
// Find the attribute which uses the specified OptionSet.
var attribute =
(from a in entityMetadata.Attributes
where a.AttributeType == AttributeTypeCode.Picklist
&& ((EnumAttributeMetadata)a).OptionSet.MetadataId
== optionSetMetadata.MetadataId
select a).FirstOrDefault();
// Check for null, since statuscode attributes on custom entities are not
// global, but their optionsets are not included in the attribute
// metadata of the entity, either.
if (attribute != null)
{
// Concatenate the name of the entity and the name of the attribute
// together to form the OptionSet name.
return String.Format("{0}{1}",
DefaultNamingService.GetNameForEntity(entityMetadata, services),
DefaultNamingService.GetNameForAttribute(
entityMetadata, attribute, services));
}
}
return DefaultNamingService.GetNameForOptionSet(
entityMetadata, optionSetMetadata, services);
}
示例10: OrganizationMetadata
internal OrganizationMetadata(EntityMetadata[] entities, OptionSetMetadataBase[] optionSets, SdkMessages messages)
{
Trace.TraceInformation("Entering {0}", new object[] {MethodBase.GetCurrentMethod().Name});
_entities = entities;
_optionSets = optionSets;
_sdkMessages = messages;
Trace.TraceInformation("Exiting {0}", new object[] {MethodBase.GetCurrentMethod().Name});
}
示例11: GenerateRelationship
public bool GenerateRelationship(RelationshipMetadataBase relationshipMetadata, EntityMetadata otherEntityMetadata, IServiceProvider services)
{
if (!GenerateEntityRelationships)
{
return false;
}
return DefaultService.GenerateRelationship(relationshipMetadata, otherEntityMetadata, services);
}
示例12: GenerateEntity
public bool GenerateEntity(EntityMetadata entityMetadata, IServiceProvider services)
{
if (!DefaultService.GenerateEntity(entityMetadata, services)) { return false; }
if (!EntityMetadata.ContainsKey(entityMetadata.LogicalName))
{
EntityMetadata.Add(entityMetadata.LogicalName, entityMetadata);
}
return !EntitiesToSkip.Contains(entityMetadata.LogicalName);
}
示例13: GetProcessedFilter
public static FilterCriteriaSet GetProcessedFilter(EntityMetadata metadata)
{
var subquery =
string.Format(
"[{0}].[{1}].[{2}] IN (SELECT DISTINCT ProcessId FROM WorkflowHistory WHERE SecurityUserId IS NOT NULL AND SecurityUserId = '{3}')",
metadata.SchemaName, metadata.TableName, metadata.PrimaryKeyPropertyName,
(Guid)CommonSettings.CurrentEmployee.SecurityUserId);
return FilterCriteriaSet.And.Custom(subquery);
}
示例14: RefreshContent
public void RefreshContent(EntityMetadata newEmd)
{
emd = newEmd;
entityPropertyGrid.SelectedObject = new EntityMetadataInfo(emd);
LoadAttributes(emd.Attributes);
LoadOneToManyRelationships(emd.OneToManyRelationships);
LoadManyToOneRelationships(emd.ManyToOneRelationships);
LoadManyToManyRelationships(emd.ManyToManyRelationships);
LoadPrivileges(emd.Privileges);
}
示例15: Logic
public Logic(IOrganizationService service, ConnectionDetail connectionDetail, EntityMetadata metadata, string tempPostFix, bool migrateData)
{
SupportsExecuteMultipleRequest = connectionDetail.OrganizationMajorVersion >= Crm2013 ||
(connectionDetail.OrganizationMajorVersion >= Crm2011 && int.Parse(connectionDetail.OrganizationVersion.Split('.')[3]) >= Rollup12);
Service = service;
TempPostfix = tempPostFix;
MigrateData = migrateData;
ValidLanguageCodes = GetValidLanguageCodes();
Metadata = metadata;
}