I have the following Model class:
public class Invoice
{
public string Id{ get; set; }
public string BlobInfoContentType { get; set; }
}
Now the issue is that in my database, the content columns has this name:
BlobInfo.ContentType
This is how I use it with Dapper:
using (SqlConnection connection = new SqlConnection(db))
{
const string UserQuery = @"
SELECT Id, BlobInfo.ContentType
FROM Invoice
WHERE Id = @Id
";
await connection.OpenAsync();
var invoice = await connection
.QuerySingleOrDefaultAsync<Invoice>
(
UserQuery,
request
);
}
It fails with:
Failed with exception.System.Data.SqlClient.SqlException (0x80131904): The multi-part identifier could not be bound
I've tried various forms of annotations on my model class but they don't seem to have any effect. I also tried using "AS, like this BlobInfo.ContentType as BlobInfoContentType
but it did not work either.
How to map Multi Part Column names to class properties?
User contributions licensed under CC BY-SA 3.0