/// <summary> /// 根据主键获取实体 /// </summary> /// <param name="id">实体主键</param> /// <returns></returns> public override TEntity Get(TPrimaryKey id) { var sql = StatementFactory.Select <TEntity>(Dialect.MSSQL, new { Id = id }); //string sql = "select * from " + typeof(TEntity).ToString() + " where id=@id"; DynamicParameters para = new DynamicParameters(); para.Add("id", id); return(_dbContext.connection.Query <TEntity>(sql, para).FirstOrDefault()); }
private protected override SelectStatementBuilder <Race> DefaultSelectQuery() => StatementFactory.Select <Race>() .Join <Race, Location>((nameof(Race.LocationId), nameof(Location.Id)))
private protected override SelectStatementBuilder <SkierEvent> DefaultSelectQuery() => StatementFactory.Select <SkierEvent>() .Join <SkierEvent, RaceData>((nameof(SkierEvent.RaceDataId), nameof(RaceData.Id)))
private protected override SelectStatementBuilder <RaceData> DefaultSelectQuery() => StatementFactory.Select <RaceData>().Join <RaceData, EventType>((nameof(RaceData.EventTypeId), nameof(EventType.Id)));
/// <summary> /// 获取实体集合 /// </summary> /// <returns></returns> public override List <TEntity> GetAllList() { return(_dbContext.connection.Query <TEntity>(StatementFactory.Select <TEntity>(Dialect.MSSQL)).ToList()); }
private protected virtual SelectStatementBuilder <T> DefaultSelectQuery() => StatementFactory.Select <T>();