/// <summary> /// Returns the default access enum formatted as a translated string. /// </summary> /// <param name="defaultAccess"></param> /// <returns></returns> public static string DefaultAccess(DefaultAccess defaultAccess) { switch (defaultAccess) { case Settings.DefaultAccess.Allow: return(Strings.AllowAccess); case Settings.DefaultAccess.Deny: return(Strings.DenyAccess); case Settings.DefaultAccess.Unrestricted: return(Strings.UnrestrictedAccess); default: throw new NotImplementedException(); } }
private static void Main(string[] args) { Fluently.Configure() .Database(MsSqlConfiguration.MsSql2012) .Mappings(m => m.FluentMappings.AddFromAssemblyOf <User>() .Conventions.Add(Table.Is(x => "tbl" + x.EntityType.Name)) .Conventions.Add(DefaultAccess.CamelCaseField(CamelCasePrefix.Underscore)) .Conventions.Add(ForeignKey.EndsWith("_Id"))) .ExposeConfiguration(BuildSchema).BuildConfiguration(); Console.WriteLine("enter for exit"); Console.ReadLine(); }
private static Action <FluentNHibernate.Conventions.IConventionFinder> GetConventions() { return(mappings => { mappings.Add <PrimaryKeyConvention>(); mappings.Add <TableNameConvention>(); mappings.Add <EnumConvention>(); mappings.Add(ForeignKey.EndsWith("Id")); mappings.Add(DefaultCascade.None()); mappings.Add(DefaultAccess.Property()); mappings.Add(DefaultLazy.Always()); mappings.Add(LazyLoad.Always()); }); }
protected override void PostProcessConfiguration(Configuration config) { base.PostProcessConfiguration(config); Fluently.Configure(config).Mappings(m => { foreach (string assemblyName in FluentMappingAssemblies) { /* HBM Mappings der Konfiguration hinzufügen. */ m.HbmMappings.AddFromAssembly(Assembly.Load(assemblyName)); /* Fluent Mappings der Konfiguration hinzufügen. */ m.FluentMappings.AddFromAssembly(Assembly.Load(assemblyName)) .Conventions.Add(Table.Is(x => "tbl" + x.EntityType.Name)) .Conventions.Add(DefaultAccess.CamelCaseField(CamelCasePrefix.Underscore)); } }).BuildConfiguration(); // noch vor BuilConfiguration() steht: .ExposeConfiguration(cfg => new SchemaExport(cfg).Create(true, true)) (wenn es benötigt wird. }
/// <summary> /// See interface docs. /// </summary> /// <param name="access"></param> public void Initialise(Access access) { if (access == null) { throw new ArgumentNullException("access"); } lock (_SyncLock) { _Initialised = true; _DefaultAccess = access.DefaultAccess; _Cidrs = new List <Cidr>(); foreach (var address in access.Addresses) { _Cidrs.Add(Cidr.Parse(address)); } Access = access; } }
public static ISessionFactory BuildSessionFactory() { var configuration = Fluently .Configure() .Database( MsSqlConfiguration.MsSql2008 .ConnectionString(str => str.FromConnectionStringWithKey("sparrow")) .ShowSql ) .Mappings(m => { m.AutoMappings .Add( AutoMap.AssemblyOf <User>(new AutoMapConfiguration()) .IgnoreBase <EntityBase>() .Conventions.Add( new EnumConvention(), new NotNullConvention(), ConventionBuilder.Class.Always(c => c.Schema("dbo")), ConventionBuilder.Id.Always(id => id.GeneratedBy.GuidComb()), ConventionBuilder.HasMany.Always(many => { many.Inverse(); many.Cascade.AllDeleteOrphan(); }), PrimaryKey.Name.Is(id => "ID"), ForeignKey.EndsWith("ID"), DefaultAccess.CamelCaseField(CamelCasePrefix.Underscore) ) ); }) .BuildConfiguration(); // Uncomment to automatically generate database tables. // new SchemaExport(configuration).Create(false, true); return(configuration.BuildSessionFactory()); }