public BaseUsage GetMetadataAttributeUsageById(long Id) { using (MetadataPackageManager mpm = new MetadataPackageManager()) { var q = from p in mpm.MetadataPackageRepo.Get() from u in p.MetadataAttributeUsages where u.Id == Id // && p.Id.Equals(parentId) select u; return(q.FirstOrDefault()); } }
private static List <LinkElementModel> getChildrenFromMetadataPackage(long metadataPackageId, LinkElementPostion pos) { MetadataPackageManager metadataPackageManager = new MetadataPackageManager(); try { MetadataPackage metadataPackage = metadataPackageManager.MetadataPackageRepo.Get(metadataPackageId); List <LinkElementModel> tmp = new List <LinkElementModel>(); foreach (var attr in metadataPackage.MetadataAttributeUsages) { LinkElementComplexity complexity = LinkElementComplexity.None; LinkElementType type = LinkElementType.ComplexMetadataAttribute; complexity = attr.MetadataAttribute.Self is MetadataSimpleAttribute ? LinkElementComplexity.Simple : LinkElementComplexity.Complex; //type = attr.Member.Self is MetadataSimpleAttribute // ? LinkElementType.SimpleMetadataAttribute // : LinkElementType.ComplexMetadataAttribute; type = LinkElementType.MetadataNestedAttributeUsage; tmp.Add( new LinkElementModel( 0, attr.Id, type, attr.Label, "", pos, complexity, attr.Description) ); } return(tmp); } finally { metadataPackageManager.Dispose(); } }