示例#1
0
        public override void Update() {
            if (Session.FindObject<PersistentAssemblyInfo>(info => info.Name == MasterDetailDynamicAssembly) == null) {
                var persistentAssemblyInfo = new DynamicAssemblyBuilder(Session).Build(DMDCustomer, DMDOrder, DMDOrderLine, MasterDetailDynamicAssembly);
                var persistentClassInfo = persistentAssemblyInfo.PersistentClassInfos.Where(info => info.Name == DMDCustomer).Single();
                var persistentCoreTypeMemberInfo = new PersistentCoreTypeMemberInfo(persistentClassInfo.Session);
                persistentCoreTypeMemberInfo.TypeAttributes.Add(new PersistentVisibleInDetailViewAttribute(persistentCoreTypeMemberInfo.Session));
                persistentCoreTypeMemberInfo.TypeAttributes.Add(new PersistentVisibleInListViewAttribute(persistentCoreTypeMemberInfo.Session));
                persistentCoreTypeMemberInfo.TypeAttributes.Add(new PersistentVisibleInLookupListViewAttribute(persistentCoreTypeMemberInfo.Session));
                persistentCoreTypeMemberInfo.TypeAttributes.Add(new PersistentPersistentAliasAttribute(persistentCoreTypeMemberInfo.Session) { AliasExpression = "DMDOrders.Min(OrderDate)" });
                persistentCoreTypeMemberInfo.Name = "FirstOrderDate";
                persistentCoreTypeMemberInfo.DataType=DBColumnType.DateTime;
                var codeTemplateInfo = new CodeTemplateInfo(persistentCoreTypeMemberInfo.Session);
                var codeTemplate = new CodeTemplate(codeTemplateInfo.Session) { TemplateType = TemplateType.XPCalculatedPropertyMember };
                codeTemplate.SetDefaults();
                codeTemplate.Name = "CalculatedProperty";
                codeTemplateInfo.TemplateInfo = codeTemplate;

                persistentCoreTypeMemberInfo.CodeTemplateInfo = codeTemplateInfo;
                persistentClassInfo.OwnMembers.Add(persistentCoreTypeMemberInfo);
                ObjectSpace.FindObjectSpaceByObject(persistentClassInfo).CommitChanges();
            }
        }
示例#2
0
 static void createClass() {
     var persistentClassInfo = new PersistentClassInfo(UnitOfWork) { PersistentAssemblyInfo = _persistentAssemblyInfo, CodeTemplateInfo = new CodeTemplateInfo(UnitOfWork) };
     var codeTemplate = new CodeTemplate(UnitOfWork) { TemplateType = TemplateType.Class, CodeDomProvider = CodeDomProvider.VB };
     codeTemplate.SetDefaults();
     persistentClassInfo.CodeTemplateInfo.TemplateInfo = codeTemplate;
 }