107 lines
3.8 KiB
C#
107 lines
3.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Kreta.Framework.Collections;
|
|
using Kreta.Framework.Collections.Generic;
|
|
|
|
namespace Kreta.Framework.Entities.Generic
|
|
{
|
|
/// <summary>
|
|
/// Entitások adatbázisműveleteit végző objektumának őse
|
|
/// </summary>
|
|
public abstract class EntityDataAccessor<EntityType> : IEntityDataAccessor<EntityType>, IEntityDataAccessor
|
|
where EntityType : Kreta.Framework.Entities.Entity
|
|
{
|
|
|
|
protected abstract IEntityDBHelper<EntityType> dbhelper
|
|
{
|
|
get;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Beállítja a létrehozóját egy entitásnak
|
|
/// </summary>
|
|
/// <param name="entity">A beállítandó entitás</param>
|
|
protected void SetEntityCreator(EntityType entity, DateTime timestamp, int uniqueidentifier)
|
|
{
|
|
entity.EntityCreated = timestamp;
|
|
entity.EntityCreator = uniqueidentifier;
|
|
//entity.EntitySubsCreator = UserContext.Instance.SubstituteEmployeePrintName;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Beállítja a módosítóját egy entitásnak
|
|
/// </summary>
|
|
/// <param name="entity">A beállítandó entitás</param>
|
|
protected void SetEntityModifier(EntityType entity, DateTime timestamp, int uniqueidentifier)
|
|
{
|
|
entity.EntityLastChanged = timestamp;
|
|
entity.EntityModifier = uniqueidentifier;
|
|
//entity.EntitySubsLastModifier = UserContext.Instance.SubstituteEmployeePrintName;
|
|
}
|
|
|
|
#region ISDAEntityDataAccessor<EntityType> Members
|
|
|
|
public abstract bool LoadEntity(EntityType entity, int entityId);
|
|
|
|
public virtual bool FilteredLoadEntity(EntityType entity, int entityId, ColumnFilterMode columnFilterMode, IEnumerable<string> columns)
|
|
{
|
|
return LoadEntity(entity, entityId);
|
|
}
|
|
|
|
public abstract void LoadWithFilter(IEntityCollection<EntityType> collection, string filter, Dictionary<string, object> commandParameters);
|
|
|
|
public virtual void LoadWithFilter(IEntityCollection<EntityType> collection, string filter, ColumnFilterMode columnFilterMode, IEnumerable<string> columns, Dictionary<string, object> commandParameters)
|
|
{
|
|
LoadWithFilter(collection, filter, commandParameters);
|
|
}
|
|
|
|
public abstract void InsertEntity(EntityType entity);
|
|
|
|
public abstract bool UpdateEntity(EntityType entity);
|
|
|
|
public abstract bool UpdateAssociations(EntityType entity);
|
|
|
|
public abstract void DeleteEntity(EntityType entity, bool logikai = true);
|
|
|
|
#endregion
|
|
|
|
#region IEntityDataAccessor Members
|
|
|
|
bool IEntityDataAccessor.LoadEntity(Entity entity, int entityId)
|
|
{
|
|
return LoadEntity((EntityType)entity, entityId);
|
|
}
|
|
|
|
bool IEntityDataAccessor.FilteredLoadEntity(Entity entity, int entityId, ColumnFilterMode columnFilterMode, IEnumerable<string> columns)
|
|
{
|
|
return FilteredLoadEntity((EntityType)entity, entityId, columnFilterMode, columns);
|
|
}
|
|
|
|
void IEntityDataAccessor.LoadWithFilter(IEntityCollection collection, string filter, Dictionary<string, object> commandParameters)
|
|
{
|
|
LoadWithFilter((IEntityCollection<EntityType>)collection, filter, commandParameters);
|
|
}
|
|
|
|
void IEntityDataAccessor.InsertEntity(Entity entity)
|
|
{
|
|
InsertEntity((EntityType)entity);
|
|
}
|
|
|
|
bool IEntityDataAccessor.UpdateEntity(Entity entity)
|
|
{
|
|
return UpdateEntity((EntityType)entity);
|
|
}
|
|
|
|
bool IEntityDataAccessor.UpdateAssociations(Entity entity)
|
|
{
|
|
return UpdateAssociations((EntityType)entity);
|
|
}
|
|
|
|
void IEntityDataAccessor.DeleteEntity(Entity entity, bool logikai)
|
|
{
|
|
DeleteEntity((EntityType)entity, logikai);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|