forked from DapperLib/DapperAOT
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Estimated row count hint (DapperLib#31)
* stab at estimate row count * intermediate * nearly there * fix member-name output * fixup build output
- Loading branch information
Showing
38 changed files
with
845 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/Dapper.AOT.Analyzers/Internal/EstimatedRowCountState.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
|
||
namespace Dapper.Internal; | ||
|
||
internal readonly struct EstimatedRowCountState : IEquatable<EstimatedRowCountState> | ||
{ | ||
public readonly int Count; | ||
public readonly string? MemberName; | ||
public bool HasValue => Count > 0 || MemberName is not null; | ||
|
||
public EstimatedRowCountState(string memberName) | ||
{ | ||
Count = 0; | ||
MemberName = memberName; | ||
} | ||
|
||
public EstimatedRowCountState(int count) | ||
{ | ||
Count = count; | ||
MemberName = null; | ||
} | ||
|
||
public override bool Equals(object obj) => obj is EstimatedRowCountState other && Equals(other); | ||
|
||
public bool Equals(EstimatedRowCountState other) | ||
=> Count == other.Count && MemberName == other.MemberName; | ||
|
||
public override int GetHashCode() | ||
=> Count + (MemberName is null ? 0 : MemberName.GetHashCode()); | ||
|
||
public override string ToString() => MemberName is null | ||
? Count.ToString() : MemberName; | ||
} |
Oops, something went wrong.