@@ -30,41 +30,45 @@ int operationTimeout
3030 int writeTimeout
3131 )
3232 {
33- await using var dbContext = client ( ) ;
34- var executeStrategy = dbContext . Database . CreateExecutionStrategy ( ) ;
35- await executeStrategy . ExecuteAsync ( async ( ) => await dbContext . Database . ExecuteSqlRawAsync (
36- $ "UPSERT INTO `{ SloTable . Name } ` (Guid, Id, PayloadStr, PayloadDouble, PayloadTimestamp) " +
37- "VALUES (@Guid, @Id, @PayloadStr, @PayloadDouble, @PayloadTimestamp)" ,
38- new YdbParameter
39- {
40- DbType = DbType . String ,
41- ParameterName = "Guid" ,
42- Value = sloTable . Guid . ToString ( )
43- } ,
44- new YdbParameter
45- {
46- DbType = DbType . Int32 ,
47- ParameterName = "Id" ,
48- Value = sloTable . Id
49- } ,
50- new YdbParameter
51- {
52- DbType = DbType . String ,
53- ParameterName = "PayloadStr" ,
54- Value = sloTable . PayloadStr
55- } ,
56- new YdbParameter
57- {
58- DbType = DbType . Double ,
59- ParameterName = "PayloadDouble" ,
60- Value = sloTable . PayloadDouble
61- } ,
62- new YdbParameter
63- {
64- DbType = DbType . DateTime2 ,
65- ParameterName = "PayloadTimestamp" ,
66- Value = sloTable . PayloadTimestamp
67- } ) ) ;
33+ await using var context = client ( ) ;
34+ var executeStrategy = context . Database . CreateExecutionStrategy ( ) ;
35+ await executeStrategy . ExecuteAsync ( async ( ) =>
36+ {
37+ await using var dbContext = client ( ) ;
38+ return await dbContext . Database . ExecuteSqlRawAsync (
39+ $ "UPSERT INTO `{ SloTable . Name } ` (Guid, Id, PayloadStr, PayloadDouble, PayloadTimestamp) " +
40+ "VALUES (@Guid, @Id, @PayloadStr, @PayloadDouble, @PayloadTimestamp)" ,
41+ new YdbParameter
42+ {
43+ DbType = DbType . String ,
44+ ParameterName = "Guid" ,
45+ Value = sloTable . Guid . ToString ( )
46+ } ,
47+ new YdbParameter
48+ {
49+ DbType = DbType . Int32 ,
50+ ParameterName = "Id" ,
51+ Value = sloTable . Id
52+ } ,
53+ new YdbParameter
54+ {
55+ DbType = DbType . String ,
56+ ParameterName = "PayloadStr" ,
57+ Value = sloTable . PayloadStr
58+ } ,
59+ new YdbParameter
60+ {
61+ DbType = DbType . Double ,
62+ ParameterName = "PayloadDouble" ,
63+ Value = sloTable . PayloadDouble
64+ } ,
65+ new YdbParameter
66+ {
67+ DbType = DbType . DateTime2 ,
68+ ParameterName = "PayloadTimestamp" ,
69+ Value = sloTable . PayloadTimestamp
70+ } ) ;
71+ } ) ;
6872
6973 return ( 1 , StatusCode . Success ) ;
7074 }
@@ -75,9 +79,9 @@ await executeStrategy.ExecuteAsync(async () => await dbContext.Database.ExecuteS
7579 int readTimeout
7680 )
7781 {
78- await using var dbContext = client ( ) ;
79- await dbContext . SloEntities
80- . FirstAsync ( table => table . Guid == select . Guid && table . Id == select . Id ) ;
82+ // await using var dbContext = client();
83+ // await dbContext.SloEntities
84+ // .FirstAsync(table => table.Guid == select.Guid && table.Id == select.Id);
8185
8286 return ( 0 , StatusCode . Success , null ) ;
8387 }
0 commit comments