using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using AutoMapper;
using Util.Applications;
using Util.Applications.Dtos;
using Util.Datas.Queries;
using Util.Domains.Repositories;
namespace Util.Tests.Samples {
///
/// 数据传输对象样例
///
public class DtoSample : DtoBase {
///
/// 名称
///
[Required(ErrorMessage = "名称不能为空" )]
public string Name { get; set; }
///
/// 忽略值
///
[IgnoreMap]
public string IgnoreValue { get; set; }
///
/// 创建空集合
///
public static List EmptyList() {
return new List();
}
}
///
/// 查询服务样例
///
public class QueryServiceSample : QueryServiceBase {
public QueryServiceSample( IRepositorySample repository ) : base( repository ) {
}
///
/// 创建查询对象
///
/// 查询参数
protected override IQueryBase CreateQuery( QueryParameterSample parameter ) {
return new Query( parameter ).WhereIfNotEmpty( t => t.Name == parameter.Name );
}
///
/// 查询时是否跟踪对象
///
protected override bool IsTracking => true;
}
}