当前位置: 首页>>代码示例>>C#>>正文


C# EntityInfo.GetMember方法代码示例

本文整理汇总了C#中EntityInfo.GetMember方法的典型用法代码示例。如果您正苦于以下问题:C# EntityInfo.GetMember方法的具体用法?C# EntityInfo.GetMember怎么用?C# EntityInfo.GetMember使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EntityInfo的用法示例。


在下文中一共展示了EntityInfo.GetMember方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Create

 public static EntityMemberMask Create(EntityInfo entity, string propertiesOrGroups)
 {
     var invalidNames = new StringList();
       var mask = new EntityMemberMask(propertiesOrGroups, entity);
       var props = propertiesOrGroups.SplitNames(',', ';');
       foreach (var name in props) {
     //first try member
     if (string.IsNullOrWhiteSpace(name))
       continue;
     var grp = entity.GetPropertyGroup(name);
     if (grp != null) {
       foreach (var m in grp.Members)
     mask.Set(m);
       continue;
     }
     var member = entity.GetMember(name);
     if (member != null) {
       mask.Set(member);
       continue;
     }
     //name is invalid
     invalidNames.Add(name);
       }
       if (invalidNames.Count > 0)
     Util.Throw("Properties/subgroups [{0}] not found in entity {1}.", string.Join(",", invalidNames), entity.EntityType);
       return mask;
 }
开发者ID:yuanfei05,项目名称:vita,代码行数:27,代码来源:EntityMemberMask.cs

示例2: ParseMemberNames

 public static IList<EntityKeyMemberInfo> ParseMemberNames(EntityInfo entity, string names, bool ordered = false, Action<string> errorAction = null)
 {
     var specs = StringHelper.SplitNames(names);
       var mList = new List<EntityKeyMemberInfo>();
       foreach(var spec in specs) {
     bool desc = false;
     string[] parts;
     if(ordered) {
       parts = StringHelper.SplitNames(spec, ':');
       if(parts.Length > 2) {
     if(errorAction != null) errorAction(spec);
     continue;
       }
       string strDesc = parts.Length == 1 ? "asc" : parts[1];
       switch(strDesc.ToLowerInvariant()) {
     case "":  case "asc": desc = false; break;
     case "desc": desc = true; break;
     default:
       if(errorAction != null)
         errorAction(spec);
       continue;
       }//switch
     }//if ordered
     else
       parts = new string[] { spec, null };
     var member = entity.GetMember(parts[0]);
     if(member == null) {
       if(errorAction != null)
     errorAction(spec);
     }
     mList.Add(new EntityKeyMemberInfo(member, desc));
       }//foreach spec
       return mList;
 }
开发者ID:yuanfei05,项目名称:vita,代码行数:34,代码来源:EntityAttributeHelper.cs

示例3: ToHistoryEntry

 public static DataHistoryEntry ToHistoryEntry(this IDataHistory history, EntityInfo entity)
 {
     if(history == null)
     return null;
       var dict = new Dictionary<string, object>();
       var xmlDoc = new XmlDocument();
       xmlDoc.LoadXml(history.EntityData);
       foreach(var nd in xmlDoc.DocumentElement.ChildNodes) {
     var elem = nd as XmlElement;
     if(elem == null) continue;
     var name = elem.Name;
     var member = entity.GetMember(name);
     if(member == null) continue;
     var value = ConvertHelper.ChangeType(elem.InnerText, member.DataType);
     dict[name] = value;
       }
       return new DataHistoryEntry() { EntryId = history.Id, EntityType = entity.EntityType, PrimaryKeyValue = history.EntityPrimaryKey,
               Action = history.Action, CreatedOn = history.CreatedOn, CreatedByUserId = history.CreatedByUserId, TransactionId = history.TransactionId,
               Values = dict };
 }
开发者ID:yuanfei05,项目名称:vita,代码行数:20,代码来源:DataHistoryExtensions.cs

示例4: CheckMemberName

 private string CheckMemberName(string baseName, EntityInfo entity, string trySuffix = null)
 {
     var result = baseName;
       if (entity.GetMember(result) == null)
     return result;
       // For entity references we might have occasional match of baseName with the FK column name. To avoid adding numbers, we try to add "Ref" at the end.
       if (!string.IsNullOrEmpty(trySuffix)) {
     result = baseName + trySuffix;
     if (entity.GetMember(result) == null)
       return result;
       }
       // try adding number at the end.
       for (int i = 1; i < 10; i++) {
     result = baseName + i;
     if (entity.GetMember(result) == null)
       return result;
       }
       Util.Throw("Failed to generate property name for entity {0}, base name {1}", entity.Name, baseName);
       return null;
 }
开发者ID:yuanfei05,项目名称:vita,代码行数:20,代码来源:DbFirstAppBuilder.cs

示例5: Apply

 public override void Apply(AttributeContext context, Attribute attribute, EntityInfo entity)
 {
     if (string.IsNullOrWhiteSpace(this.GroupName)) {
     context.Log.Error("Group name may not be empty. Entity: {0}.", entity.Name);
     return;
       }
       var names =  StringHelper.SplitNames(this.MemberNames);
       foreach (var name in names) {
     var member = entity.GetMember(name);
     if (member == null) {
       context.Log.Error("PropertyGroup '{0}', entity {1}: member {2} not found.", this.GroupName, entity.Name, name);
       continue;
     }
     var grp = entity.GetPropertyGroup(this.GroupName, create: true);
     if (!grp.Members.Contains(member))
       grp.Members.Add(member);
       }//foreach
 }
开发者ID:yuanfei05,项目名称:vita,代码行数:18,代码来源:EntityModelAttributesImpl.cs


注:本文中的EntityInfo.GetMember方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。