C# how to map Multi Part Column names to class properties?


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:


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


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?

asked on Stack Overflow Jul 6, 2020 by hdfushlfudsh • edited Jul 6, 2020 by Preben Huybrechts

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0