Shawn de Wet
Shawn de Wet

Reputation: 5976

ServiceStack.OrmLite for PostgreSQL returning lowercase property names for dynamic sql query that defines PascalCase column names

I have the following dynamic SQL query generated by my code:

SELECT
 "public"."member_contact"."member_id" AS MemberId
 ,  "public"."member_contact"."contact_id" AS ContactId
 ,  "public"."member_contact"."modified_by" AS ModifiedBy
 ,  "public"."member_contact"."lm_prog" AS LmProg
 ,  "public"."member_contact"."created_by" AS CreatedBy
 ,  "public"."member_contact"."cr_prog" AS CrProg
 ,  "public"."member_contact"."id" AS Id
 ,  "public"."member_contact"."modified_date" AS ModifiedDate
 ,  "public"."member_contact"."created_date" AS CreatedDate
FROM "public"."member_contact"

I then run this through a ServiceStack Service Handler method, like so:

var records = await Db.QueryAsync(sqlStatements.SelectStatement, p);, which returns an IEnumerable<dynamic>.

The problem I have is that the records contains the property names in all lowercase (so memberid as opposed to MemberId, etc)

How can I force the IEnumerable<dynamic> to return the property names as per the naming of the columns in the SQL Statement?

Upvotes: 0

Views: 41

Answers (1)

mythz
mythz

Reputation: 143284

QueryAsync is Dapper's API.

In OrmLite you can execute Custom SQL with:

var rows = await Db.SqlListAsync<MemberContact>(sql);

The Dynamic ResultSets also lists other ways you can execute custom SQL queries.

Upvotes: 1

Related Questions