本文整理汇总了C#中EntityMetadata类的典型用法代码示例。如果您正苦于以下问题:C# EntityMetadata类的具体用法?C# EntityMetadata怎么用?C# EntityMetadata使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EntityMetadata类属于命名空间,在下文中一共展示了EntityMetadata类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: EntityExtractor
public EntityExtractor(string entityName, List<EnviromentValue> enviromentValues, EntityMetadata entityDefine)
{
_entityDefine = entityDefine;
EntityName = entityName;
_enviromentValues = enviromentValues;
}
开发者ID:yalunwang,项目名称:DotnetSpider,代码行数:7,代码来源:EntityExtractor.cs
示例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}";
}
开发者ID:albertakhmetov,项目名称:LiteRepository,代码行数:35,代码来源:SqlServerGenerator.cs
示例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);
}
开发者ID:snugglesftw,项目名称:Crm,代码行数:29,代码来源:TypeMappingService.cs
示例4: AttributePicker
public AttributePicker(EntityMetadata emd, IEnumerable<string> alreadySelectedAttributes, IOrganizationService service)
{
this.emd = emd;
this.alreadySelectedAttributes = alreadySelectedAttributes;
this.service = service;
InitializeComponent();
}
开发者ID:NORENBUCH,项目名称:XrmToolBox,代码行数:7,代码来源:AttributePicker.cs
示例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);
}
}
开发者ID:Quodnon,项目名称:XrmToolBox,代码行数:27,代码来源:MainControl.cs
示例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(";");
}
开发者ID:jesuslpm,项目名称:EntityLite,代码行数:7,代码来源:NpgsqlEntityLiteProvider.cs
示例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;
}
开发者ID:dmelnikov,项目名称:DWKit,代码行数:34,代码来源:Sync.cs
示例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);
}
}
开发者ID:neronotte,项目名称:XrmToolBox,代码行数:25,代码来源:MainControl.cs
示例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);
}
开发者ID:cesugden,项目名称:Scripts,代码行数:38,代码来源:NamingService.cs
示例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});
}
开发者ID:snugglesftw,项目名称:Crm,代码行数:8,代码来源:OrganizationMetadata.cs
示例11: GenerateRelationship
public bool GenerateRelationship(RelationshipMetadataBase relationshipMetadata, EntityMetadata otherEntityMetadata, IServiceProvider services)
{
if (!GenerateEntityRelationships)
{
return false;
}
return DefaultService.GenerateRelationship(relationshipMetadata, otherEntityMetadata, services);
}
开发者ID:daryllabar,项目名称:DLaB.Xrm.XrmToolBoxTools,代码行数:8,代码来源:CodeWriterFilterService.cs
示例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);
}
开发者ID:ganpathv,项目名称:DLaB.Xrm.XrmToolBoxTools,代码行数:10,代码来源:CodeWriterFilterService.cs
示例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);
}
开发者ID:dmelnikov,项目名称:DWKit,代码行数:10,代码来源:CommonMethods.cs
示例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);
}
开发者ID:NORENBUCH,项目名称:XrmToolBox,代码行数:10,代码来源:EntityPropertiesControl.cs
示例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;
}
开发者ID:ganpathv,项目名称:DLaB.Xrm.XrmToolBoxTools,代码行数:10,代码来源:Logic.cs
示例16: GetEntityCaptionAttribute
public static AttributeDescription GetEntityCaptionAttribute(EntityMetadata metadata)
{
string[] columnCaptions = new string[] { "Code", "IdNumber", "NumberId", "Number", "Name", "Caption", "Id" };
int i = -1;
var properties = metadata.PlainAttributes.Select(pa => pa.PropertyName);
while (++i < columnCaptions.Count() && !properties.Contains(columnCaptions[i])) { }
return i < columnCaptions.Count() ? metadata.GetAttributeByPropertyName(columnCaptions[i]) : null;
}
开发者ID:dmelnikov,项目名称:DWKit,代码行数:10,代码来源:CommonMethods.cs
示例17: DeleteBudgetDictionary
public static ExternalMethodCallResult DeleteBudgetDictionary(EntityMetadata metadata,
Dictionary<string, string> parameters,
IEnumerable<DynamicEntity> entities)
{
ExternalMethodCallResult res = new ExternalMethodCallResult(true);
List<string> views = null;
if (parameters.ContainsKey("Views"))
{
views = parameters["Views"].Split(',').Select(c => c.Trim()).ToList();
}
List<string> forms = null;
if (parameters.ContainsKey("Forms"))
{
forms = parameters["Forms"].Split(',').Select(c => c.Trim()).ToList();
}
string budgetColumnName = "BudgetId";
if (parameters.ContainsKey("Column"))
{
budgetColumnName = parameters["Column"];
}
foreach (DynamicEntity e in entities)
{
if(parameters.ContainsKey("ValidateStoredProcedure"))
{
var paramsIn = new Dictionary<string, object>();
paramsIn.Add(budgetColumnName, e.GetId());
var paramsOut = new Dictionary<string, object>();
paramsOut.Add("ErrorMessage", string.Empty);
DynamicRepository.ExecuteSP(parameters["ValidateStoredProcedure"],paramsIn,paramsOut);
if (!string.IsNullOrWhiteSpace(paramsOut["ErrorMessage"] as string))
{
res.AddGlobalError(paramsOut["ErrorMessage"].ToString());
res.Sucess = false;
}
}
}
if (res.Sucess)
{
foreach (DynamicEntity e in entities)
{
Budget b = new Budget();
b.DeleteEntityByViews(budgetColumnName, e.GetId(), views);
b.DeleteEntityByForms(budgetColumnName, e.GetId(), forms);
}
}
return res;
}
开发者ID:dmelnikov,项目名称:DWKit,代码行数:55,代码来源:BudgetMethods.cs
示例18: CreateValidTypeName
string INamingService.GetNameForEntity(EntityMetadata entityMetadata, IServiceProvider services)
{
if (_knowNames.ContainsKey(entityMetadata.MetadataId.Value.ToString()))
{
return _knowNames[entityMetadata.MetadataId.Value.ToString()];
}
var name = string.IsNullOrEmpty(StaticNamingService.GetNameForEntity(entityMetadata)) ? entityMetadata.SchemaName : StaticNamingService.GetNameForEntity(entityMetadata);
var str2 = CreateValidTypeName(name);
_knowNames.Add(entityMetadata.MetadataId.Value.ToString(), str2);
return str2;
}
开发者ID:snugglesftw,项目名称:Crm,代码行数:11,代码来源:NamingService.cs
示例19: LoadRibbonCommands
private void LoadRibbonCommands(EntityMetadata emd)
{
var commands = service.RetrieveMultiple(new QueryExpression("ribboncommand")
{
ColumnSet = new ColumnSet(true),
Criteria = new FilterExpression
{
Conditions =
{
new ConditionExpression("commanddefinition", ConditionOperator.Like, "%Library=\"$webresource:%"),
new ConditionExpression("entity", ConditionOperator.Equal, emd.LogicalName)
}
}
});
foreach (var command in commands.Entities)
{
var commandDoc = new XmlDocument();
commandDoc.LoadXml(command.GetAttributeValue<string>("commanddefinition"));
var actionsNode = commandDoc.SelectSingleNode("CommandDefinition/Actions");
foreach (XmlNode actionNode in actionsNode.ChildNodes)
{
if (actionNode.Attributes == null)
continue;
var libraryNode = actionNode.Attributes["Library"];
if (libraryNode == null)
{
continue;
}
var libraryName = libraryNode.Value;
if (libraryName.Split(':').Length == 1)
continue;
var script = new Script();
script.EntityLogicalName = emd.LogicalName;
script.EntityName = emd.DisplayName.UserLocalizedLabel.Label;
script.ScriptLocation = libraryName.Split(':')[1];
script.MethodCalled = actionNode.Attributes["FunctionName"].Value;
script.Event = "";
script.Attribute = "";
script.AttributeLogicalName = "";
script.Name = string.Empty;
script.Type = "Ribbon Command";
Scripts.Add(script);
}
}
}
开发者ID:NielsMinnee,项目名称:XrmToolBox,代码行数:53,代码来源:ScriptsManager.cs
示例20: EntityMetadataBuilder
public EntityMetadataBuilder(string entityName)
{
//Initialise Meatdata
Entity = new EntityMetadata
{
LogicalName = entityName.ToLower(),
SchemaName = entityName,
IsActivity = false,
IsActivityParty = false,
OwnershipType = OwnershipTypes.UserOwned
};
}
开发者ID:YOTOV-LIMITED,项目名称:CrmAdo,代码行数:12,代码来源:EntityMetadataBuilder.cs
注:本文中的EntityMetadata类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论