/// <summary> /// 使用这个 CommandSet 方法的方法,不和 RepositoryTrans 使用同一事务对象 /// </summary> /// <param name="tc"></param> /// <returns></returns> private CommandSet <T> GetCommandSet(TransContext tc) { var cs = tc.CommandSet <T>(); this.Sql = cs; return(cs); }
/// <summary> /// 使用这个 CommandSet 方法的方法,不和 RepositoryTrans 使用同一事务对象 /// </summary> /// <param name="tc"></param> /// <returns></returns> private CommandSet <T> GetCommandSet(TransContext tc) { var cs = tc.CommandSet <T>(new SqlProvider <T>(Dialect), Throws); this.Sql = cs; return(cs); }
public string UpdateItem(long id, int amountOfLikes) { using (var db = new TransContext()) { return(db.editLikes(id, amountOfLikes)); } }
public IEnumerable <TransportationML> GetTransInfo() { using (var db = new TransContext()) { var items = db.Transportations.AsQueryable().ToList(); List <TransportationML> transportationMLs = new List <TransportationML>(); double min = 0; double max = 0; foreach (var item in items) { var input = new ModelInput(); input.VehicleType = item.vehicleType; input.RoutToCountry = item.routToCountry; ModelOutput result = ConsumeModel.Predict(input); if (result.Score > max) { max = result.Score; } if (result.Score < min) { min = result.Score; } transportationMLs.Add(new TransportationML { transportationInfo = item, likeProbability = result.Score }); } foreach (var item in transportationMLs) { item.percentage = (int)Math.Round(100 * (item.likeProbability + Math.Abs(min)) / Math.Abs(max - min)); } return(transportationMLs); } }
public async static Task loopWithTimer(TimeSpan timeSpan) { //List<TransportationInfo> items = new List<TransportationInfo>(); List <TransportationInfo> items = FetchDataFromWebSite(); //RabbitMQSet(items); TransContext ctx = new TransContext(); ctx.SetMany(items); await Task.Delay(timeSpan); }
private DataService() { transInfo = new List <TransportationInfo>(); db = new TransContext(); subscribeIntoDataFromTheQueue(); }
public TransController(TransContext context) { _context = context; }