/// <summary> /// Constructor. /// </summary> /// <param name="tableName">Table name</param> protected EntityMap(string tableName) { if (string.IsNullOrWhiteSpace(tableName)) //TODO: Use code contracts? { throw new ArgumentNullException("tableName"); } Table(tableName); Id(x => x.Id); if (typeof(IMustHaveTenant).IsAssignableFrom(typeof(TEntity))) { Map(Reveal.Member <TEntity>("TenantId")).Column("TenantId").Not.Nullable().Index(string.Format("tenantid_{0}", tableName)); } if (typeof(IMayHaveTenant).IsAssignableFrom(typeof(TEntity))) { Map(Reveal.Member <TEntity>("TenantId")).Column("TenantId").Nullable(); } //if (typeof(ISoftDelete).IsAssignableFrom(typeof(TEntity))) //{ // Where("IsDeleted = 0"); //TODO: Test with other DBMS then SQL Server //} if (typeof(IMustHaveTenant).IsAssignableFrom(typeof(TEntity))) { ApplyFilter <MustHaveTenantFilter>(); } if (typeof(IMayHaveTenant).IsAssignableFrom(typeof(TEntity))) { ApplyFilter <MayHaveTenantFilter>(); } }
public ProcessMap() { Table("NTFE_Process"); //HACK:允许由应用设置,增加应用友好 Id(m => m.ID).GeneratedBy.Assigned(); Map(m => m.CreateTime); Map(m => m.FinishTime).Nullable(); Map(m => m.Priority); Map(m => m.Status).CustomType <ProcessStatus>(); Map(m => m.Title).Length(500); Map(m => m.ParentProcessId); //调度标识字段 Map(Reveal.Member <Process>("_chargingBy")).Column("ChargingBy").Length(50); //HACK:由于Component的lazyload在当前NH版本下无效,改为单独维护WorkflowData字段 //Component<Process.InternalWorkflowInstance>(Reveal.Member<Process>("Instance") // , m => m.Map(x => x.Serialized).Column("WorkflowData")) // .LazyLoad(); References(m => m.Originator).Column("OriginatorId").LazyLoad(); References(m => m.ProcessType).Column("ProcessTypeId").LazyLoad(); HasMany <ProcessDataField>(Reveal.Member <Process>("_dataFields")) .Cascade.SaveUpdate() .LazyLoad() .KeyColumn("ProcessId"); }
public DeductionMap() { Table("deductions"); Id(x => x.Id); // References<Employee>(Reveal.Member<Deduction>("_employee")); References <Employee>(x => x.Employee); References <Salary>(Reveal.Member <Deduction>("_salary")); Map(Reveal.Member <Deduction>("_amortization")); Map(Reveal.Member <Deduction>("_paid")); Map(x => x.Mode); Map(x => x.hasBalance); Component <MonetaryValue>(x => x.Total, c => { c.Map(x => x.PreciseValue).Column("total"); c.Map(x => x.Code); }).ColumnPrefix("deduction_"); Component <Date>(x => x.DateGranted, c => { c.Map(x => x.Year); c.Map(x => x.Month); c.Map(x => x.Day); }).ColumnPrefix("granted_"); HasMany <DeductionPayment>(Reveal.Member <Deduction>("_payments")); }
/// <inheritdoc /> public CaseMap() : base() { Table("case_card"); Id(x => x.Id, "id").GeneratedBy.Assigned(); Map(x => x.Created, "created"); Map(x => x.Updated, "updated"); Map(x => x.ActivatedPlanInstructions, "activated_plan_instructions").Nullable(); Map(Reveal.Member <Case>("_status"), "status").Nullable(); Map(x => x.IndexValue, "index_value").Nullable(); HasMany(x => x.CaseUsers) .Cascade.All().Inverse() .Fetch .Subselect().KeyColumn("case_id"); References(x => x.Type) .Column("case_type_id"); References(x => x.CaseFolder) .Cascade.SaveUpdate() .Column("case_folder_id"); Not.LazyLoad(); }
public HumanSettingMap() { Table("NTFE_Activity"); Map(m => m.SlotCount); Map(m => m.SlotMode).CustomType <HumanSetting.SlotDistributionMode>(); Map(m => m.Url).Length(500); Map(Reveal.Member <HumanSetting>("_actions")).Column("Actions").Length(500); Component(m => m.ActionerRule, m => { m.Map(Reveal.Member <HumanActionerRule>("_scripts")).Column("ActionerRule_Script").Length(500); }); Component(m => m.EscalationRule, m => { m.Map(x => x.ExpirationMinutes).Column("EscalationRule_ExpirationMinutes").Nullable(); m.Map(x => x.NotifyRepeatMinutes).Column("EscalationRule_NotifyRepeatMinutes").Nullable(); m.Map(x => x.NotifyTemplateName).Column("EscalationRule_NotifyTemplateName").Nullable(); m.Map(x => x.GotoActivityName).Column("EscalationRule_GotoActivityName").Nullable(); m.Map(x => x.RedirectTo).Column("EscalationRule_RedirectTo").Nullable(); m.References(x => x.TimeZone).Column("EscalationRule_TimeZoneId").LazyLoad(); }); DiscriminatorValue("human"); }
public StickerPackMap() { Table("StickerPacks"); Id(x => x.Id).GeneratedBy.Assigned(); Map(x => x.Name).Not.Nullable(); Map(x => x.Alias).Not.Nullable(); Map(x => x.Claps).Not.Nullable(); Map(x => x.CreatedAt).Not.Nullable(); References(x => x.CreatedBy, "CreatedById") .Not.Nullable() .Cascade.Persist() .Cascade.Delete() .LazyLoad(); HasMany <Donation>(Reveal.Member <StickerPack>("Donations")) .Access.CamelCaseField(Prefix.Underscore) .Cascade.AllDeleteOrphan() .ExtraLazyLoad() .Inverse(); HasManyToMany <Tag>(Reveal.Member <StickerPack>("Tags")) .Access.CamelCaseField(Prefix.Underscore) .ExtraLazyLoad() .Cascade.All() .ParentKeyColumn("StickerPackId") .ChildKeyColumn("TagId") .Table("StickerTags_Pivot"); }
public ExpenseReportMap() { Not.LazyLoad(); Id(x => x.Id).GeneratedBy.GuidComb(); Map(x => x.Number).Not.Nullable().Length(5); Map(x => x.Title).Not.Nullable().Length(200); Map(x => x.Description).Not.Nullable().Length(4000); Map(x => x.CreatedDate); Map(x => x.Status).Not.Nullable().CustomType <ExpenseReportStatusType>(); References(x => x.Submitter).Not.Nullable().Column("SubmitterId"); References(x => x.Approver).Column("ApproverId"); HasMany(Reveal.Member <ExpenseReport, IEnumerable <AuditEntry> >("_auditEntries")) .AsList(part => { part.Column("Sequence"); part.Type <int>(); }) .Table("AuditEntry") .Cascade.AllDeleteOrphan() .KeyColumn("ExpenseReportId") .Component(part => { part.References(x => x.Employee).Column("EmployeeId"); part.Map(x => x.ArchivedEmployeeName); part.Map(x => x.Date); part.Map(x => x.BeginStatus).CustomType <ExpenseReportStatusType>(); part.Map(x => x.EndStatus).CustomType <ExpenseReportStatusType>(); }) .Access.CamelCaseField() .Not.LazyLoad(); }
public ProcessTypeMap() { Table("NTFE_ProcessType"); //HACK:ProcessType启用二级缓存,对象属于不可变 Cache.ReadWrite().Region("ProcessTypes"); Id(m => m.ID); Map(m => m.Name).Length(50); Map(m => m.Description).Length(500); Map(m => m.CreateTime); Map(m => m.IsCurrent); Map(m => m.Version); Map(m => m.Group).Column("GroupName").Length(50); Component <ProcessType.WorkflowDefinition>(Reveal.Member <ProcessType>("Workflow") , m => m.Map(x => x.Serialized) .Column("WorkflowData") //narchar(max) https://github.com/ali-ent/NTFE-BPM/issues/1 .CustomType("StringClob")); //HACK:https://github.com/codesharp/infrastructure/blob/master/upgrade.md //.LazyLoad(); HasMany <ActivitySetting>(Reveal.Member <ProcessType>("_settings")) .Cascade.SaveUpdate() .LazyLoad().KeyColumn("ProcessTypeId"); }
public GroupMap() { Id(p => p.Id).GeneratedBy.Assigned(); Map(p => p.Name).Not.Nullable(); HasManyToMany(p => p.Users) .Access .CamelCaseField() .Table("GroupUser") .ParentKeyColumn("GroupId") .ChildKeyColumn("UserId") .LazyLoad(); HasManyToMany(p => p.Invites) .Access .CamelCaseField() .Table("UserInviteGroup") .ParentKeyColumn("GroupId") .ChildKeyColumn("UserInviteId") .LazyLoad(); Map(p => p.DateCreated).Not.Nullable(); Map(p => p.DateModified).Not.Nullable(); Map(Reveal.Member <Group>("tenantId")).Not.Nullable(); ApplyFilter <MultitenantFilter>("TenantId = :TenantId"); }
/// <summary> /// Searches for a customer who has the specified account. /// </summary> /// <param name="accountNumber">The account number.</param> /// <returns></returns> public ICustomer FindByAccount(string accountNumber) { return(GetSession().QueryOver <CustomerBase>() .Left.JoinQueryOver(Reveal.Member <CustomerBase>("_accounts")) .WhereRestrictionOn(x => ((Account)x).AccountNumber).IsLike(accountNumber) .SingleOrDefault()); }
public MontlyBudgetMap() { Id(x => x.Id); Map(Reveal.Member <MontlyBudget>("ExecutionDay")); Map(Reveal.Member <MontlyBudget>("Category")); Map(x => x.Available); }
public EmployeeMappings() { Table("Employees"); Not.LazyLoad(); Id(Reveal.Member <Employee>("EmployeeId")) .GeneratedBy.Identity(); Version(Reveal.Member <Employee>("Version")) .CustomSqlType("rowversion") .CustomType <byte[]>() .Generated.Always(); Map(Reveal.Member <Employee>("Name")); Map(Reveal.Member <Employee>("Address")); HasMany <Contact>(Reveal.Member <Employee>("Contacts")) .KeyColumn("EmployeeId") .Component(c => { c.Map(Reveal.Member <Contact>("Value")) .Column("Contact") .Not.Nullable(); c.Map(Reveal.Member <Contact>("Kind")) .Column("ContactKind") .CustomSqlType("integer") .CustomType <ContactKind>() .Not.Nullable(); }) .Table("Contacts") .Not.LazyLoad(); References <EmployeeType>(Reveal.Member <Employee>("EmployeeType")) .Column("EmployeeTypeId") .Not.Nullable() .Cascade.None(); }
public ExpenseReportMap() { Not.LazyLoad(); Id(x => x.Id).GeneratedBy.GuidComb(); Map(x => x.Number).Not.Nullable().Length(5); Map(x => x.Title).Not.Nullable().Length(200); Map(x => x.Description).Not.Nullable().Length(4000); Map(x => x.Status).Not.Nullable().CustomType <ExpenseReportStatusType>(); // New property mappings Map(x => x.MilesDriven).Column("MilesDriven"); Map(x => x.Created).Column("Created"); Map(x => x.FirstSubmitted).Column("FirstSubmitted"); Map(x => x.LastSubmitted).Column("LastSubmitted"); Map(x => x.LastWithdrawn).Column("LastWithdrawn"); Map(x => x.LastCancelled).Column("LastCancelled"); Map(x => x.LastApproved).Column("LastApproved"); Map(x => x.LastDeclined).Column("LastDeclined"); Map(x => x.Total).Column("Total"); References(x => x.Submitter).Column("SubmitterId"); References(x => x.Approver).Column("ApproverId"); HasMany(Reveal.Member <ExpenseReport, IEnumerable <AuditEntry> >("_auditEntries")) .AsList(part => { part.Column("Sequence"); part.Type <int>(); }) .Table("AuditEntry") .Cascade.AllDeleteOrphan() .KeyColumn("ExpenseReportId") .Component(part => { part.References(x => x.Employee).Column("EmployeeId"); part.Map(x => x.EmployeeName).Length(200); part.Map(x => x.Date); part.Map(x => x.EndStatus).CustomType <ExpenseReportStatusType>(); part.Map(x => x.BeginStatus).CustomType <ExpenseReportStatusType>(); }) .Access.CamelCaseField() .Not.LazyLoad(); HasMany(Reveal.Member <ExpenseReport, IEnumerable <Expense> >("_expenses")) .AsList(part => { part.Column("Sequence"); part.Type <int>(); }) .Table("Expense") .Cascade.AllDeleteOrphan() .KeyColumn("ExpenseReportId") .Component(part => { part.Map(x => x.Description); part.Map(x => x.Amount); }) .Access.CamelCaseField() .Not.LazyLoad(); }
public HumanActivityInstanceMap() { Table("NTFE_ActivityInstance"); Map(m => m.ReferredBookmarkName).Length(50); Map(Reveal.Member <HumanActivityInstance>("_actioners")).Column("Actioners"); Map(Reveal.Member <HumanActivityInstance>("_alreadyActioners")).Column("AlreadyActioners"); DiscriminatorValue("human"); }
public void Override(FluentNHibernate.Automapping.AutoMapping <Page> mapping) { mapping.HasMany <Link>(x => x.Links) .Access.CamelCaseField(Prefix.Underscore) .Cascade.AllDeleteOrphan() .Inverse(); mapping.Map(Reveal.Member <Page>("InnerHtml")).Length(10000); //Lenght > 4000 => nvarchar(max) }
public MovieMap() { Id(x => x.Id); DiscriminateSubClassesOnColumn("LicensingModel"); Map(x => x.Name); //Map(x => x.LicensingModel).CustomType<int>(); Map(Reveal.Member <Movie>("LicensingModel")).CustomType <int>(); }
public void Override(AutoMapping <Entity> mapping) { mapping.Component(x => x.Component, c => { c.Map(Reveal.Member <Component>("fieldName1"), "columnName1"); c.Map(Reveal.Member <Component>("fieldName2"), "columnName2"); c.Map(Reveal.Member <Component>("fieldName3"), "columnName3"); }); }
public CatMap() { Id(i => i.Id).GeneratedBy.Identity(); HasMany <Vaccination>(Reveal.Member <Cat>("_vaccinations")).Cascade.All().Inverse(); HasMany <CatRecord>(Reveal.Member <Cat>("_catRecords")).Cascade.All().Inverse(); HasMany <CatEvent>(Reveal.Member <Cat>("_domainEvents")).Cascade.All().Inverse(); Map(i => i.Neutered); Map(i => i.Name); }
public WorkingDayMap() { Table("NTFE_TimeZone_WorkingDay"); Id(m => m.ID); Map(m => m.Date); Map(m => m.DayOfWeek).CustomType <DayOfWeek?>(); Map(m => m.Description); Map(Reveal.Member <WorkingDay>("_hours")).Column("WorkingHours"); }
public AccountMap() { Table("Cooper_Account"); Id(m => m.ID); Map(m => m.Name).Length(255); Map(m => m.CreateTime); Map(Reveal.Member <Account>("_password")).Column("Password").Length(255); //严格一对一实现 HasOne <Profile>(Reveal.Member <Account>("_profile")).Cascade.SaveUpdate(); }
public void Can_use_references_using_string_name_on_private_property() { new MappingTester <StringTarget>() .ForMapping(map => { map.Id(x => x.Id); map.References(Reveal.Member <StringTarget>("PrivateObject")); }) .Element("class/many-to-one").HasAttribute("name", "PrivateObject"); }
public void Can_use_manytomany_using_string_name_on_private_property() { new MappingTester <StringTarget>() .ForMapping(map => { map.Id(x => x.Id); map.HasManyToMany <ExampleClass>(Reveal.Member <StringTarget>("PrivateObject")); }) .Element("class/bag").HasAttribute("name", "PrivateObject"); }
private void MapProductDetReference(string entityName) { References(Reveal.Member <Product, ProductDet>(entityName)) .Columns("ProductionLine", "ProductNumber") .ReadOnly() .EntityName(entityName) .Cascade.All() .Fetch.Join() .Not.LazyLoad(); }
public PayrollReportMap() { Table("payroll_reports"); Id(x => x.Id); Map(x => x.Month); Map(x => x.Year); Map(x => x.MonthlyUnit); Map(x => x.Total); HasManyToMany <PayrollRecord>(Reveal.Member <PayrollReport>("_records")).Cascade.All(); }
public NodeMap() { Id(x => x.Id, "NodeId").GeneratedBy.HiLo("[dbo].[Ids]", "NextHigh", "10", "EntityName = 'Node'"); Map(x => x.Name).Not.Nullable(); HasManyToMany <Node>(Reveal.Member <Node>("LinksInternal")) .AsSet() .Table("Node_Node") .ParentKeyColumn("NodeId1") .ChildKeyColumn("NodeId2"); }
public MyClassMap() { HasMany(Reveal.Member <ActionsHolder, IEnumerable <TypeToEntity> >("innerList")) .Table("NavTypeToNavActionEntity") .Component(c => { c.Map(x => x.Type); c.References(x => x.NavigationActionEntity).Not.LazyLoad(); }) ; }
public ProjectMap() { Map(x => x.Name); Map(x => x.Stage).CustomType <int>(); Map(x => x.Price); HasMany <ProjectInvolement>(Reveal.Member <Project>("InvolementsInternal")) .Not.LazyLoad() .Inverse() .Cascade.None(); }
public ErrorRecordMap() { Table("NTFE_ErrorRecord"); Id(m => m.ID); Map(m => m.CreateTime); Map(m => m.Reason); Map(Reveal.Member <ErrorRecord>("_isDeleted")).Column("IsDeleted"); References(m => m.Process).Column("ProcessId").LazyLoad().Cascade.None(); DiscriminateSubClassesOnColumn("ErrorType").Length(50); }
public AccountMap() { LazyLoad(); Id(c => c.Id).GeneratedBy.Assigned(); Component(c => c.FullName, m => { m.Map(Reveal.Member <FullName>("_firstName")).Column("FirstName").Length(30).Not.Nullable(); m.Map(Reveal.Member <FullName>("_lastName")).Column("LastName").Length(40).Not.Nullable(); }); Component(c => c.Email, m => m.Map(Reveal.Member <Email>("_address")).Column("EmailAddress").Not.Nullable()); }
public ActivityInstanceBaseMap() { Table("NTFE_ActivityInstance"); Id(m => m.ID); Map(Reveal.Member <ActivityInstanceBase>("_workflowActivityInstanceId")).Column("WorkflowActivityInstanceId"); Map(m => m.ActivityName).Length(50); Map(m => m.FlowNodeIndex); Map(m => m.ProcessId); Map(m => m.CreateTime); Map(m => m.FinishTime).Nullable(); DiscriminateSubClassesOnColumn("ActivityInstanceType"); }