You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I love your library. Would it be possible to add a mapping for GUIDs? We store GUIDs in an oracle RAW 16. Why oracle doesn't have a specific field type for GUIDs, I don't understand. However, I need to convert the byte array to GUID. And in my case, I have to do Endian flip. I don't know if others have to do this Endian flip.
Below is an example of what I am doing. The AWN_SA_ID is the column name that is mapped by dapper. AwnSaId is the guid that I actually use.
public class Dto
{
public byte[] AWN_SA_ID
{
set => AwnSaId = FlipEndian(new Guid(value));
}
public Guid AwnSaId { get; set; }
public string Jcn { get; set; }
public string Hsc { get; set; }
}
private static Guid FlipEndian(Guid guid)
{
var newBytes = new byte[16];
var oldBytes = guid.ToByteArray();
for (var i = 8; i < 16; i++)
{
newBytes[i] = oldBytes[i];
}
newBytes[3] = oldBytes[0];
newBytes[2] = oldBytes[1];
newBytes[1] = oldBytes[2];
newBytes[0] = oldBytes[3];
newBytes[5] = oldBytes[4];
newBytes[4] = oldBytes[5];
newBytes[6] = oldBytes[7];
newBytes[7] = oldBytes[6];
return new Guid(newBytes);
}
public void DapperStoredProcedure()
{
List<Dto> data;
var connStr = ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
using (var connection = new OracleConnection(connStr))
{
var values = new OracleDynamicParameters();
values.Add("i_uic", Uic, OracleMappingType.Varchar2, ParameterDirection.Input);
values.Add("o_cur", dbType: OracleMappingType.RefCursor, direction: ParameterDirection.Output);
data = connection.Query<Dto>("jcn_exports.get_work_notifications", values, commandType: CommandType.StoredProcedure).ToList();
}
Console.WriteLine($"The count is {data.Count}");
WriteGuid(data);
}
The text was updated successfully, but these errors were encountered:
Hi,
I love your library. Would it be possible to add a mapping for GUIDs? We store GUIDs in an oracle RAW 16. Why oracle doesn't have a specific field type for GUIDs, I don't understand. However, I need to convert the byte array to GUID. And in my case, I have to do Endian flip. I don't know if others have to do this Endian flip.
Below is an example of what I am doing. The AWN_SA_ID is the column name that is mapped by dapper. AwnSaId is the guid that I actually use.
The text was updated successfully, but these errors were encountered: