/// <summary> /// Eğer contextin lazy loading özelliği etkinleştirilmiş ise ilişkili nesnelere erişilmeye çalışıldığında getirmeyi sağlar. /// This method provides to get relation of entities, if the related context's lazy loading property is enabled. /// </summary> /// <typeparam name="TEntity">Entity type.</typeparam> /// <param name="foreignColumnName">Foreign column name.</param> /// <returns></returns> public IList <TEntity> GetRelations <TEntity>(string foreignColumnName, object value) { if (_ormConfiguration.LazyLoadingEnabled) { if (string.IsNullOrEmpty(foreignColumnName) || value == null) { return(new List <TEntity>()); } string key = string.Format("{0}|{1}|{2}", typeof(TEntity).Name, foreignColumnName, value); if (CacheManager.getInstance.Contains(key)) { return(OrmHelper.getInstance.ConvertTo <List <TEntity> >(CacheManager.getInstance.Get(key))); } else { var provider = DBProviderFactory <TEntity> .GetDbProvider(_ormConfiguration); var relationEntities = provider.GetRelations(foreignColumnName, value); CacheManager.getInstance.AddOrUpdate(key, relationEntities); return(relationEntities); } } else { return(new List <TEntity>()); } }
/// <summary> /// Bu metot tabloyu truncate edebilmenizi sağlar. /// This method truncates table. /// </summary> /// <typeparam name="TEntity">Entity class.</typeparam> /// <param name="forceTruncate">If forceTruncate=true truncate table operation will be forced.</param> /// <returns></returns> public void TruncateTable <TEntity>(bool forceTruncate = false) { dynamic provider = DBProviderFactory <TEntity> .GetDbProvider(_ormConfiguration); provider.TruncateTable(forceTruncate); }
/// <summary> /// Eğer nesneniz ModelBase soyut sınıfından kalıtım alıyor ise bu metot tabloyu create veya alter edebilmenizi sağlar. /// This method runs the create/alter table, only if the entity inherit the ModelBase abstract class. /// </summary> /// <typeparam name="TEntity">Entity class.</typeparam> /// <returns></returns> public void CreateOrAlterTable <TEntity>() { dynamic provider = DBProviderFactory <TEntity> .GetDbProvider(_ormConfiguration); provider.CreateOrAlterTable(); }
/// <summary> /// Bu metot tabloyu drop edebilmenizi sağlar. /// This method drops the table. /// </summary> /// <typeparam name="TEntity">Entity class.</typeparam> /// <param name="forceDrop">If forceDrop=true drop table process will be forced.</param> public void DropTable <TEntity>(bool forceDrop = false) { dynamic provider = DBProviderFactory <TEntity> .GetDbProvider(_ormConfiguration); provider.DropTable(forceDrop); }
/// <summary> /// Eğer nesneniz ModelBase soyut sınıfından kalıtım alıyor ise bu metot veritabanınızı oluşturmayı sağlar. /// This method initializes the database, only if the entities inherit the ModelBase abstract class. /// </summary> /// <typeparam name="TContext">Entity context class.</typeparam> /// <returns></returns> public void InitializeDatabase <TContext>() { dynamic provider = DBProviderFactory <TContext> .GetDbProvider(_ormConfiguration); provider.CreateTables(); }