11using Internal ;
2- using JetBrains . Annotations ;
32using Linq2db . Ydb ;
43using Linq2db . Ydb . Internal ;
54using LinqToDB ;
@@ -21,7 +20,8 @@ static SloTableContext()
2120
2221 public sealed class Linq2dbClient ( string connectionString )
2322 {
24- public DataConnection Open ( ) => new ( new DataOptions ( ) . UseConnectionString ( "YDB" , connectionString ) ) ;
23+ public DataConnection Open ( )
24+ => new ( new DataOptions ( ) . UseConnectionString ( "YDB" , connectionString ) ) ;
2525 }
2626
2727 protected override Linq2dbClient CreateClient ( Config config ) => new ( config . ConnectionString ) ;
@@ -71,7 +71,21 @@ protected override async Task<int> Save(Linq2dbClient client, SloTable sloTable,
7171 db . CommandTimeout = readTimeout ;
7272
7373 var t = db . GetTable < SloRow > ( ) ;
74- return await t . FirstOrDefaultAsync ( r => r . Guid == select . Guid && r . Id == select . Id ) ;
74+
75+ // Намеренно «используем» все столбцы, чтобы ReSharper не ругался на «неиспользуемые» поля.
76+ var row = await t
77+ . Where ( r => r . Guid == select . Guid && r . Id == select . Id )
78+ . Select ( r => new
79+ {
80+ r . Guid ,
81+ r . Id ,
82+ r . PayloadStr ,
83+ r . PayloadDouble ,
84+ r . PayloadTimestamp
85+ } )
86+ . FirstOrDefaultAsync ( ) ;
87+
88+ return row ;
7589 }
7690
7791 protected override async Task < int > SelectCount ( Linq2dbClient client )
@@ -80,14 +94,13 @@ protected override async Task<int> SelectCount(Linq2dbClient client)
8094 return await db . GetTable < SloRow > ( ) . CountAsync ( ) ;
8195 }
8296
83- [ UsedImplicitly ( ImplicitUseTargetFlags . WithMembers ) ]
8497 [ Table ( SloTable . Name ) ]
85- public sealed class SloRow
98+ private sealed class SloRow ( DateTime payloadTimestamp , double payloadDouble , string ? payloadStr , int id , Guid guid )
8699 {
87- [ Column ] public Guid Guid { get ; set ; }
88- [ Column ] public int Id { get ; set ; }
89- [ Column ] public string ? PayloadStr { get ; set ; }
90- [ Column ] public double PayloadDouble { get ; set ; }
91- [ Column ] public DateTime PayloadTimestamp { get ; set ; }
100+ [ Column ] public Guid Guid { get ; } = guid ;
101+ [ Column ] public int Id { get ; } = id ;
102+ [ Column ] public string ? PayloadStr { get ; } = payloadStr ;
103+ [ Column ] public double PayloadDouble { get ; } = payloadDouble ;
104+ [ Column ] public DateTime PayloadTimestamp { get ; } = payloadTimestamp ;
92105 }
93106}
0 commit comments