using System.Data; namespace YLErp.Modules.UnderlyingModule { /// /// 场内期权数据服务 /// public class ExchangeOptionDataService : YLBaseService { public ExchangeOptionDataService(OptUserInfo userInfo) : base(userInfo) { } public ExchangeOptionDataService(YLBaseService baseService) : base(baseService) { } /// /// 查询exchange_list_option /// public IPagedList SearchList(ExchangeOptionReq req) { var predicate = PredicateBuilder.True(); if (!string.IsNullOrEmpty(req.ContractCode)) { predicate = predicate.And(d => d.ContractCode.Contains(req.ContractCode)); } if (!string.IsNullOrEmpty(req.UnderlyingCode)) { predicate = predicate.And(d => d.UnderlyingCode.Contains(req.UnderlyingCode)); } if (!string.IsNullOrEmpty(req.OptionType)) { predicate = predicate.And(d => d.OptionType.Contains(req.OptionType)); } if (!string.IsNullOrEmpty(req.ExerciseMode)) { predicate = predicate.And(d => d.ExerciseMode.Contains(req.ExerciseMode)); } if (req.MaturityDateStart != DateTime.MinValue) { predicate = predicate.And(d => d.MaturityDate >= req.MaturityDateStart); } if (req.MaturityDateEnd != DateTime.MinValue) { predicate = predicate.And(d => d.MaturityDate <= req.MaturityDateEnd); } if (!string.IsNullOrEmpty(req.MarketCode)) { predicate = predicate.And(d => d.MarketCode == req.MarketCode); } var query = DbContext.exchange_list_option.Where(predicate); return query.ToPagedList(req); } public IEnumerable GetSelectItems(string underlyingCode) { return DbContext.exchange_list_option.Where(n => n.UnderlyingCode == underlyingCode).OrderByDescending(n => n.id).ToArray(); } } public class ExchangeOptionReq : PagedQueryModel { /// /// 合约代码 /// public string ContractCode { get; set; } /// /// 标的代码 /// public string UnderlyingCode { get; set; } /// /// 看涨看跌 /// public string OptionType { get; set; } /// /// 行权方式 /// public string ExerciseMode { get; set; } public DateTime MaturityDateStart { get; set; } public DateTime MaturityDateEnd { get; set; } /// /// 市场代码 /// public string MarketCode { get; set; } } }