0

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?

1
  • This is it exactly! thanks a mil for the pointer...I should have found that one. Commented Aug 29, 2024 at 8:43

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.