Refactorings.

pull/81/head
Halil İbrahim Kalkan 9 years ago
parent 1213bf2233
commit 95eeb92303

@ -6,7 +6,7 @@ namespace Volo.Abp.Application.Services.Dtos
/// Implements common properties for entity based DTOs.
/// </summary>
/// <typeparam name="TPrimaryKey">Type of the primary key</typeparam>
public class EntityDto<TPrimaryKey>
public class EntityDto<TPrimaryKey> : IEntityDto<TPrimaryKey>
{
/// <summary>
/// Id of the entity.

@ -0,0 +1,22 @@
namespace Volo.Abp.Application.Services.Dtos
{
///// <summary>
///// A shortcut of <see cref="IEntityDto{TPrimaryKey}"/> for most used primary key type (<see cref="int"/>).
///// </summary>
//public interface IEntityDto : IEntityDto<int>
//{
//}
/// <summary>
/// Defines common properties for entity based DTOs.
/// </summary>
/// <typeparam name="TPrimaryKey"></typeparam>
public interface IEntityDto<TPrimaryKey>
{
/// <summary>
/// Id of the entity.
/// </summary>
TPrimaryKey Id { get; set; }
}
}

@ -25,7 +25,7 @@ namespace Microsoft.Extensions.DependencyInjection
services.TryAddTransient<TDbContext>();
services.TryAddSingleton(serviceProvider =>
{
const string moduleName = "";
const string moduleName = ""; //TODO: Use AbpModuleDescriptor instead of module name?
var connInfoResolver = serviceProvider.GetRequiredService<IConnectionStringResolver>();

@ -2,5 +2,6 @@
{
public class AggregateRoot<TPrimaryKey> : Entity<TPrimaryKey>, IAggregateRoot<TPrimaryKey>
{
}
}

@ -79,19 +79,6 @@ namespace Volo.Abp.Domain.Entities
return false;
}
//TODO: How to handle this?
//if (this is IMayHaveTenant && other is IMayHaveTenant &&
// this.As<IMayHaveTenant>().TenantId != other.As<IMayHaveTenant>().TenantId)
//{
// return false;
//}
//if (this is IMustHaveTenant && other is IMustHaveTenant &&
// this.As<IMustHaveTenant>().TenantId != other.As<IMustHaveTenant>().TenantId)
//{
// return false;
//}
return Id.Equals(other.Id);
}

@ -1,5 +1,6 @@
using System;
using System.Reflection;
using JetBrains.Annotations;
using Volo.Abp.Reflection;
namespace Volo.Abp.Domain.Entities
@ -9,7 +10,7 @@ namespace Volo.Abp.Domain.Entities
/// </summary>
public static class EntityHelper
{
public static bool IsEntity(Type type)
public static bool IsEntity([NotNull] Type type)
{
return ReflectionHelper.IsAssignableToGenericType(type, typeof (IEntity<>));
}
@ -22,7 +23,7 @@ namespace Volo.Abp.Domain.Entities
/// <summary>
/// Gets primary key type of given entity type
/// </summary>
public static Type GetPrimaryKeyType(Type entityType)
public static Type GetPrimaryKeyType([NotNull] Type entityType)
{
foreach (var interfaceType in entityType.GetTypeInfo().GetInterfaces())
{

@ -5,7 +5,7 @@ namespace Volo.Abp.Domain.Entities
/// <summary>
/// This exception is thrown if an entity excepted to be found but not found.
/// </summary>
//[Serializable]
//TODO: [Serializable]
public class EntityNotFoundException : AbpException
{
/// <summary>

@ -2,6 +2,7 @@
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Volo.Abp.Domain.Entities;
namespace Volo.Abp.Domain.Repositories
@ -16,7 +17,7 @@ namespace Volo.Abp.Domain.Repositories
/// given predicate.
/// </summary>
/// <param name="predicate">A condition to filter entities</param>
void Delete(Expression<Func<TEntity, bool>> predicate);
void Delete([NotNull] Expression<Func<TEntity, bool>> predicate);
/// <summary>
/// Deletes many entities by function.
@ -25,6 +26,6 @@ namespace Volo.Abp.Domain.Repositories
/// given predicate.
/// </summary>
/// <param name="predicate">A condition to filter entities</param>
Task DeleteAsync(Expression<Func<TEntity, bool>> predicate);
Task DeleteAsync([NotNull] Expression<Func<TEntity, bool>> predicate);
}
}

@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Volo.Abp.Domain.Entities;
using Volo.DependencyInjection;
@ -17,12 +18,14 @@ namespace Volo.Abp.Domain.Repositories
/// Used to get all entities.
/// </summary>
/// <returns>List of all entities</returns>
[NotNull]
List<TEntity> GetList();
/// <summary>
/// Used to get all entities.
/// </summary>
/// <returns>List of all entities</returns>
[NotNull]
Task<List<TEntity>> GetListAsync();
/// <summary>
@ -30,6 +33,7 @@ namespace Volo.Abp.Domain.Repositories
/// </summary>
/// <param name="id">Primary key of the entity to get</param>
/// <returns>Entity</returns>
[NotNull]
TEntity Get(TPrimaryKey id);
/// <summary>
@ -37,6 +41,7 @@ namespace Volo.Abp.Domain.Repositories
/// </summary>
/// <param name="id">Primary key of the entity to get</param>
/// <returns>Entity</returns>
[NotNull]
Task<TEntity> GetAsync(TPrimaryKey id);
/// <summary>
@ -44,6 +49,7 @@ namespace Volo.Abp.Domain.Repositories
/// </summary>
/// <param name="id">Primary key of the entity to get</param>
/// <returns>Entity or null</returns>
[CanBeNull]
TEntity Find(TPrimaryKey id);
/// <summary>
@ -51,19 +57,22 @@ namespace Volo.Abp.Domain.Repositories
/// </summary>
/// <param name="id">Primary key of the entity to get</param>
/// <returns>Entity or null</returns>
[CanBeNull]
Task<TEntity> FindAsync(TPrimaryKey id);
/// <summary>
/// Inserts a new entity.
/// </summary>
/// <param name="entity">Inserted entity</param>
TEntity Insert(TEntity entity);
[NotNull]
TEntity Insert([NotNull] TEntity entity);
/// <summary>
/// Inserts a new entity.
/// </summary>
/// <param name="entity">Inserted entity</param>
Task<TEntity> InsertAsync(TEntity entity);
[NotNull]
Task<TEntity> InsertAsync([NotNull] TEntity entity);
/// <summary>
/// Inserts a new entity and gets it's Id.
@ -72,7 +81,7 @@ namespace Volo.Abp.Domain.Repositories
/// </summary>
/// <param name="entity">Entity</param>
/// <returns>Id of the entity</returns>
TPrimaryKey InsertAndGetId(TEntity entity);
TPrimaryKey InsertAndGetId([NotNull] TEntity entity);
/// <summary>
/// Inserts a new entity and gets it's Id.
@ -81,31 +90,33 @@ namespace Volo.Abp.Domain.Repositories
/// </summary>
/// <param name="entity">Entity</param>
/// <returns>Id of the entity</returns>
Task<TPrimaryKey> InsertAndGetIdAsync(TEntity entity);
Task<TPrimaryKey> InsertAndGetIdAsync([NotNull] TEntity entity);
/// <summary>
/// Updates an existing entity.
/// </summary>
/// <param name="entity">Entity</param>
TEntity Update(TEntity entity);
[NotNull]
TEntity Update([NotNull] TEntity entity);
/// <summary>
/// Updates an existing entity.
/// </summary>
/// <param name="entity">Entity</param>
Task<TEntity> UpdateAsync(TEntity entity);
[NotNull]
Task<TEntity> UpdateAsync([NotNull] TEntity entity);
/// <summary>
/// Deletes an entity.
/// </summary>
/// <param name="entity">Entity to be deleted</param>
void Delete(TEntity entity);
void Delete([NotNull] TEntity entity);
/// <summary>
/// Deletes an entity.
/// </summary>
/// <param name="entity">Entity to be deleted</param>
Task DeleteAsync(TEntity entity);
Task DeleteAsync([NotNull] TEntity entity);
/// <summary>
/// Deletes an entity by primary key.

Loading…
Cancel
Save