本文整理汇总了C#中EntityMode类的典型用法代码示例。如果您正苦于以下问题:C# EntityMode类的具体用法?C# EntityMode怎么用?C# EntityMode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EntityMode类属于命名空间,在下文中一共展示了EntityMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckEntityMode
private static void CheckEntityMode(EntityMode entityMode)
{
if (EntityMode.Poco != entityMode)
{
throw new ArgumentOutOfRangeException("entityMode", "Unhandled EntityMode : " + entityMode);
}
}
示例2: FindType
public static Type FindType(string clazz, ISession session, EntityMode entityMode) {
if(IsDebugEnabled)
log.Debug("인스턴싱할 엔티티 형식을 찾습니다... clazz=[{0}], entityMode=[{1}]", clazz, entityMode);
var result = session.SessionFactory.GetEntityType(clazz, entityMode);
if(result != null) {
// lock(_syncLock)
return _entityTypeCache.GetOrAdd(clazz, result);
}
foreach(var assembly in AppDomain.CurrentDomain.GetAssemblies()) {
result = assembly.GetType(clazz, false, true);
if(result != null) {
return _entityTypeCache.GetOrAdd(clazz, result);
//lock(_syncLock)
// _entityTypeCache.AddValue(clazz, result);
//return result;
}
}
return _entityTypeCache.GetOrAdd(clazz, result);
}
示例3: Instantiate
public override object Instantiate(string clazz, EntityMode entityMode, object id)
{
if (entityMode == EntityMode.Poco)
{
Type type = this.typeResolver.ResolveType(clazz);
if (type != null)
{
if (type.GetConstructors().Any(constructor => constructor.GetParameters().Any()))
{
try
{
object instance = ObjectFactory.GetInstance(type);
this.session.SessionFactory
.GetClassMetadata(clazz)
.SetIdentifier(instance, id, entityMode);
return instance;
}
catch (Exception exception)
{
Console.WriteLine(exception);
}
}
}
}
return base.Instantiate(clazz, entityMode, id);
}
示例4: ToString
/// <summary>
///
/// </summary>
/// <param name="entity">an actual entity object, not a proxy!</param>
/// <param name="entityMode"></param>
/// <returns></returns>
public string ToString(object entity, EntityMode entityMode)
{
IClassMetadata cm = _factory.GetClassMetadata(entity.GetType());
if (cm == null)
{
return entity.GetType().FullName;
}
IDictionary<string, string> result = new Dictionary<string, string>();
if (cm.HasIdentifierProperty)
{
result[cm.IdentifierPropertyName] =
cm.IdentifierType.ToLoggableString(cm.GetIdentifier(entity, entityMode), _factory);
}
IType[] types = cm.PropertyTypes;
string[] names = cm.PropertyNames;
object[] values = cm.GetPropertyValues(entity, entityMode);
for (int i = 0; i < types.Length; i++)
{
var value = values[i];
if (Equals(LazyPropertyInitializer.UnfetchedProperty, value) || Equals(BackrefPropertyAccessor.Unknown, value))
{
result[names[i]] = value.ToString();
}
else
{
result[names[i]] = types[i].ToLoggableString(value, _factory);
}
}
return cm.EntityName + CollectionPrinter.ToString(result);
}
示例5: GetTuplizerOrNull
/// <summary>
/// Locate the contained tuplizer responsible for the given entity-mode. If
/// no such tuplizer is defined on this mapping, then return null.
/// </summary>
/// <param name="entityMode">The entity-mode for which the caller wants a tuplizer. </param>
/// <returns> The tuplizer, or null if not found. </returns>
public virtual ITuplizer GetTuplizerOrNull(EntityMode entityMode)
{
EnsureFullyDeserialized();
ITuplizer result;
_tuplizers.TryGetValue(entityMode, out result);
return result;
}
示例6: IsEqual
public override bool IsEqual(object x, object y, EntityMode entityMode, ISessionFactoryImplementor factory)
{
IEntityPersister persister = factory.GetEntityPersister(associatedEntityName);
if (!persister.CanExtractIdOutOfEntity)
{
return base.IsEqual(x, y, entityMode);
}
object xid;
if (x.IsProxy())
{
INHibernateProxy proxy = x as INHibernateProxy;
xid = proxy.HibernateLazyInitializer.Identifier;
}
else
{
xid = persister.GetIdentifier(x, entityMode);
}
object yid;
if (y.IsProxy())
{
INHibernateProxy proxy = y as INHibernateProxy;
yid = proxy.HibernateLazyInitializer.Identifier;
}
else
{
yid = persister.GetIdentifier(y, entityMode);
}
return persister.IdentifierType.IsEqual(xid, yid, entityMode, factory);
}
示例7: CriteriaCompiled
/// <summary>
///
/// </summary>
/// <param name="rootAlias"></param>
/// <param name="rootType"></param>
/// <param name="matchMode"></param>
/// <param name="entityMode"></param>
/// <param name="instance"></param>
/// <param name="classInfoProvider"></param>
public CriteriaCompiled(string rootAlias, System.Type rootType, MatchMode matchMode, EntityMode entityMode,
object instance, Func<System.Type, IPersistentClassInfo> classInfoProvider)
{
if (rootAlias == null || rootAlias.Trim().Equals(string.Empty))
throw new ArgumentException("The alias for making detached criteria cannot be empty or null", "rootAlias");
if (rootType == null)
throw new ArgumentNullException("rootType", "The type which can be used for maikng detached criteria cannot be null.");
if (instance == null)
throw new ArgumentNullException("instance", "The instance for building detached criteria cannot be null.");
if (!rootType.IsInstanceOfType(instance))
throw new ArgumentTypeException("The given instance for building detached criteria is not suitable for the given criteria type.", "instance", rootType, instance.GetType());
this.matchMode = matchMode ?? MatchMode.Exact;
this.entityMode = entityMode;
this.instance = instance;
this.classInfoProvider = classInfoProvider;
this.relationshipTree = new RelationshipTree(rootAlias, rootType);
this.criteria = DetachedCriteria.For(rootType, rootAlias);
this.restrictions = new List<ICriterion>();
this.Init();
}
示例8: GetValues
private object[] GetValues(object entity, EntityEntry entry, EntityMode entityMode, bool mightBeDirty, ISessionImplementor session)
{
object[] loadedState = entry.LoadedState;
Status status = entry.Status;
IEntityPersister persister = entry.Persister;
object[] values;
if (status == Status.Deleted)
{
//grab its state saved at deletion
values = entry.DeletedState;
}
else if (!mightBeDirty && loadedState != null)
{
values = loadedState;
}
else
{
CheckId(entity, persister, entry.Id, entityMode);
// grab its current state
values = persister.GetPropertyValues(entity, entityMode);
CheckNaturalId(persister, entry, values, loadedState, entityMode, session);
}
return values;
}
示例9: ToString
/// <summary>
///
/// </summary>
/// <param name="entity">an actual entity object, not a proxy!</param>
/// <param name="entityMode"></param>
/// <returns></returns>
public string ToString(object entity, EntityMode entityMode)
{
IClassMetadata cm = _factory.GetClassMetadata(entity.GetType());
if (cm == null)
{
return entity.GetType().FullName;
}
IDictionary<string, string> result = new Dictionary<string, string>();
if (cm.HasIdentifierProperty)
{
result[cm.IdentifierPropertyName] =
cm.IdentifierType.ToLoggableString(cm.GetIdentifier(entity, entityMode), _factory);
}
IType[] types = cm.PropertyTypes;
string[] names = cm.PropertyNames;
object[] values = cm.GetPropertyValues(entity, entityMode);
for (int i = 0; i < types.Length; i++)
{
result[names[i]] = types[i].ToLoggableString(values[i], _factory);
}
return cm.EntityName + CollectionPrinter.ToString(result);
}
示例10: CacheKey
/// <summary>
/// Construct a new key for a collection or entity instance.
/// Note that an entity name should always be the root entity
/// name, not a subclass entity name.
/// </summary>
/// <param name="id">The identifier associated with the cached data </param>
/// <param name="type">The Hibernate type mapping </param>
/// <param name="entityOrRoleName">The entity or collection-role name. </param>
/// <param name="entityMode">The entity mode of the originating session </param>
/// <param name="factory">The session factory for which we are caching </param>
public CacheKey(object id, IType type, string entityOrRoleName, EntityMode entityMode, ISessionFactoryImplementor factory)
{
key = id;
this.type = type;
this.entityOrRoleName = entityOrRoleName;
this.entityMode = entityMode;
hashCode = type.GetHashCode(key, entityMode, factory);
}
示例11: DeepCopy
public override object DeepCopy(object value, EntityMode entityMode, ISessionFactoryImplementor factory)
{
IExternalBlobConnection blobconn;
byte[] identifier;
if (this.ExtractLobData(value, out blobconn, out identifier))
return CreateLobInstance(blobconn, identifier);
return value;
}
示例12: CollectionKey
private CollectionKey(string role, object key, IType keyType, EntityMode entityMode, ISessionFactoryImplementor factory)
{
this.role = role;
this.key = key;
this.keyType = keyType;
this.entityMode = entityMode;
this.factory = factory;
hashCode = GenerateHashCode(); //cache the hashcode
}
示例13: GetTuplizer
/// <summary> Locate the tuplizer contained within this mapping which is responsible
/// for the given entity-mode. If no such tuplizer is defined on this
/// mapping, then an exception is thrown.
///
/// </summary>
/// <param name="entityMode">The entity-mode for which the caller wants a tuplizer.
/// </param>
/// <returns> The tuplizer.
/// </returns>
/// <throws> HibernateException Unable to locate the requested tuplizer. </throws>
public virtual ITuplizer GetTuplizer(EntityMode entityMode)
{
ITuplizer tuplizer = GetTuplizerOrNull(entityMode);
if (tuplizer == null)
{
throw new HibernateException("No tuplizer found for entity-mode [" + entityMode + "]");
}
return tuplizer;
}
示例14: FilterKey
public FilterKey(string name, IEnumerable<KeyValuePair<string, object>> @params, IDictionary<string, IType> types, EntityMode entityMode)
{
filterName = name;
foreach (KeyValuePair<string, object> me in @params)
{
IType type = types[me.Key];
filterParameters[me.Key] = new TypedValue(type, me.Value, entityMode);
}
}
示例15: GetHashCode
public override int GetHashCode(object x, EntityMode entityMode)
{
int hashCode = base.GetHashCode(x, entityMode);
unchecked
{
hashCode = 31*hashCode + ((DateTime) x).Kind.GetHashCode();
}
return hashCode;
}