Created
October 30, 2020 08:20
-
-
Save Zonciu/9fee7deb11d42fc7cc1d97d6507951db to your computer and use it in GitHub Desktop.
Get Grain PrimaryKey
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
public static class GrainExtensions | |
{ | |
/// <summary> | |
/// Get string Id | |
/// </summary> | |
/// <param name="grain"></param> | |
/// <returns></returns> | |
public static string GetId(this IGrainWithStringKey grain) => grain.GetPrimaryKeyString(); | |
/// <summary> | |
/// Get long Id | |
/// </summary> | |
/// <param name="grain"></param> | |
/// <returns></returns> | |
public static long GetId(this IGrainWithIntegerKey grain) => grain.GetPrimaryKeyLong(); | |
/// <summary> | |
/// Get Guid Id | |
/// </summary> | |
/// <param name="grain"></param> | |
/// <returns></returns> | |
public static Guid GetId(this IGrainWithGuidKey grain) => grain.GetPrimaryKey(); | |
/// <summary> | |
/// Get Guid + string Id | |
/// </summary> | |
/// <param name="grain"></param> | |
/// <param name="keyExtension"></param> | |
/// <returns></returns> | |
public static Guid GetId(this IGrainWithGuidCompoundKey grain, out string keyExtension) => grain.GetPrimaryKey(out keyExtension); | |
/// <summary> | |
/// Get long + string Id | |
/// </summary> | |
/// <param name="grain"></param> | |
/// <param name="keyExtension"></param> | |
/// <returns></returns> | |
public static long GetId(this IGrainWithIntegerCompoundKey grain, out string keyExtension) => grain.GetPrimaryKeyLong(out keyExtension); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment