/// <summary> /// Uses the correct nhibernate custom mapping type for an Identity Property that is based on a Concept /// </summary> /// <typeparam name="T">Concrete type of the concept, that inherits from <see cref="ConceptAs{U}"/></typeparam> /// <typeparam name="U">The primitive that is the concept is based on</typeparam> /// <param name="identityPart">Fluent NHibernate IdentityPart</param> /// <returns>Fluent NHibernate IdentityPart<</returns> public static IdentityPart ConceptOf <T, U>(this IdentityPart identityPart) where U : IEquatable <U> where T : ConceptAs <U> { identityPart.CustomType <ConceptValueType <T, U> >(); return(identityPart); }
public static IdentityPart CustomGeneratedBy(this IdentityPart idMapping, string sequenceName) { switch (NHibernateHelper.DatabaseType) { default: throw new ArgumentNullException("Unhandled database type"); case NHibernateHelper.SupportedDatabaseType.SQLEXPRESS_2012: return(idMapping.GeneratedBy.Native(sequenceName)); case NHibernateHelper.SupportedDatabaseType.SQLITE3: return(idMapping.GeneratedBy.Native(sequenceName).UnsavedValue(null)); } }
internal void GenerateGuidIdentity(IdentityPart identityPart) { /*1) Или CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; * и генерировать uuid так - select * from uuid_generate_v4()*/ /*2) Или CREATE EXTENSION pgcrypto; и вызов - select gen_random_uuid()*/ identityPart.GeneratedBy.Guid() /* * .Length(36) * .GeneratedBy * .Guid() * .Not * .Nullable() * .Default("public.gen_random_uuid()")*/; }
public static string GetIdentityPart(string identity, IdentityPart part) { if (identity == null) { throw new ArgumentNullException(); } if (!Enum.IsDefined(typeof(IdentityPart), part)) { throw new ArgumentException("part"); } string chosenOption = string.Empty; switch (part) { case IdentityPart.Domainname: chosenOption = "domain"; break; case IdentityPart.Username: chosenOption = "username"; break; default: throw new InvalidOperationException(string.Format("IdentityPart {0} not implemented.", part)); } // perform regex match Match m = Regex.Match(identity, REGEX_IDENTITYNAME); // if match was successful then return result..otherwise return empty string to avoid NullReferenceExceptions if (m.Success) { return(m.Groups[chosenOption].Value); } else { return(string.Empty); } }
protected void AssignIdentity(IdentityPart part) { part.Identifier = Guid.NewGuid().ToString("n"); }
protected void AssignIdentity(InitializingContentContext context, IdentityPart part) { part.Identifier = Guid.NewGuid().ToString("n"); }
protected void AssignIdentity(InitializingContentContext context, IdentityPart part) { part.Identifier = Guid.NewGuid().ToString("n"); }
/// <summary> /// Applies the specified identity part. /// </summary> /// <param name="identityPart">The identity part.</param> public override void Apply(IdentityPart identityPart) { identityPart.GeneratedBy.Assigned(); }
/// <summary> /// Applies the specified identity part. /// </summary> /// <param name="identityPart">The identity part.</param> public override void Apply(IdentityPart identityPart) { identityPart.GeneratedBy.GuidComb(); }
/// <summary> /// Applies the specified identity part. /// </summary> /// <param name="identityPart">The identity part.</param> public override void Apply(IdentityPart identityPart) { identityPart.GeneratedBy.HiLo("100", "Id", "100000"); }
/// <summary> /// Applies the specified identity part. /// </summary> /// <param name="identityPart">The identity part.</param> public override void Apply(IdentityPart identityPart) { identityPart.GeneratedBy.Identity(); }
/// <summary> /// Applies the specified identity part. /// </summary> /// <param name="identityPart">The identity part.</param> public abstract void Apply(IdentityPart identityPart);
protected void AssignIdentity(IdentityPart part) { part.Identifier = Guid.NewGuid().ToString("n"); }
public static IdentityPart AutoIncrement(this IdentityPart id) { return(id.GeneratedBy.Sequence("global_seq")); }
/// <summary> /// Uses the correct nhibernate custom mappingtype for an Identity Property that is based on a Concept{Guid} /// </summary> /// <typeparam name="T">Concrete type of the concept, that inherits from <see cref="ConceptAs{Guid}"/></typeparam> /// <param name="identityPart">Fluent NHibernate IdentityPart</param> /// <returns>Fluent NHibernate IdentityPart</returns> public static IdentityPart ConceptAsOracleGuid <T>(this IdentityPart identityPart) where T : ConceptAs <Guid> { identityPart.CustomType <ConceptAsOracleGuid <T> >(); return(identityPart); }