public BaseResponseDto AddEntities <T>(IEnumerable <T> entities, PaginationDto pagination = null) where T : EntityDto, new() { if (!Data.ContainsKey(typeof(T))) { Data[typeof(T)] = new ListDto { PrimaryKey = typeof(T).GetEntityPrimaryKeyName(), List = new Dictionary <object, EntityDto>() }; } var list = Data[typeof(T)].List; foreach (var entity in entities) { list[entity.GetEntityPrimaryKey()] = entity; } if (pagination != null) { Data[typeof(T)].Pagination = pagination; } return(this); }
public new T AddEntity <TEntity>(TEntity entity, PaginationDto pagination = null) where TEntity : EntityDto, new() { return(AddEntities(new List <TEntity> { entity }, pagination)); }
public BaseResponseDto AddEntity <T>(T entity, PaginationDto pagination = null) where T : EntityDto, new() { return(AddEntities(new List <T> { entity }, pagination)); }
public new T AddEntities <TEntity>(IEnumerable <TEntity> entities, PaginationDto pagination = null) where TEntity : EntityDto, new() { if (!EntityTypes.Contains(typeof(TEntity))) { throw new ArgumentException( $"Entity type {typeof(TEntity).Name} is not supported by this response type."); } return((T)base.AddEntities(entities, pagination)); }