简体   繁体   中英

Dapper Class property names with return Datatypes C#

I am trying creating the service with a parameter which will connect to the Oracle Db execute the complex query and should return the result in a JSON format. I was checking that the Dapper ORM which would help with this. As the query is complex

 SELECT 
 SICD_PRIO_CATEGORY_DESCR.DESCR, 
 STRS_SESSION3.SESSION_NUM, 
 Trunc(STRS_SESSION.START_DATE),
 STRS_SESSION3.START_DATE,
 STCD_ACT_DESCR4.DESCR AS DOSE_ACTIVITY, 
 decode(( decode(sign(( DECODE(SIGN(( Trunc(ILRS_DOSE.RESULT_DATE) ) - ( trunc(STPR_STD_ANML.START_DATE) )),-1,( Trunc(ILRS_DOSE.RESULT_DATE) ) - ( trunc(STPR_STD_ANML.START_DATE) ),( Trunc(ILRS_DOSE.RESULT_DATE) ) - ( trunc(STPR_STD_ANML.START_DATE) )+( STPR_OPTIONS.VALUEN )) )),-1,'Y',0,'N','N') ), 'N', Decode (( STPR_OPTIONS.VALUEN ), '1', trunc((( DECODE(SIGN(( Trunc(ILRS_DOSE.RESULT_DATE) ) - ( trunc(STPR_STD_ANML.START_DATE) )),-1,( Trunc(ILRS_DOSE.RESULT_DATE) ) - ( trunc(STPR_STD_ANML.START_DATE) ),( Trunc(ILRS_DOSE.RESULT_DATE) ) - ( trunc(STPR_STD_ANML.START_DATE) )+( STPR_OPTIONS.VALUEN )) )-1) /7)+1, '0', trunc(( DECODE(SIGN(( Trunc(ILRS_DOSE.RESULT_DATE) ) - ( trunc(STPR_STD_ANML.START_DATE) )),-1,( Trunc(ILRS_DOSE.RESULT_DATE) ) - ( trunc(STPR_STD_ANML.START_DATE) ),( Trunc(ILRS_DOSE.RESULT_DATE) ) - ( trunc(STPR_STD_ANML.START_DATE) )+( STPR_OPTIONS.VALUEN )) )/7)), 'Y', (trunc((( DECODE(SIGN(( Trunc(ILRS_DOSE.RESULT_DATE) ) - ( trunc(STPR_STD_ANML.START_DATE) )),-1,( Trunc(ILRS_DOSE.RESULT_DATE) ) - ( trunc(STPR_STD_ANML.START_DATE) ),( Trunc(ILRS_DOSE.RESULT_DATE) ) - ( trunc(STPR_STD_ANML.START_DATE) )+( STPR_OPTIONS.VALUEN )) ) +1)/ 7)-1) , -999) AS RESULT_WEEK

在此处输入图片说明

So in the other question I found that the Column names should match the class property also the datatype.

public class StudyData
{
 public string DESCR,
 public string SESSION_NUM
}

Can the return type be string for all the columns or it needs to be specific return type. Also DateTime will refer to both the Dates(like 18-DEC-12 and 18-DEC-12 07.52.25.977272000 AM -08:00) because I dont see Date Datatype in C#. I am new to C# programming, any help is greatly appreciated

Datatype of the property should match with the datatype of the column. For example if you have Id column with int datatype, then your property in class must have int datatype.

public int Id{ get; set; }

C# does have datetime datatype please use datetime as datatype of the columns which are holding date data.

public datetime createdDate { get; set; }

In your case

public class StudyData
    {
        public string DESCR { get; set; }
        public string SESSION_NUM { get; set; }
        public DateTime START_DATE { get; set; }
        public int RESULT_WEEK { get; set; }
    }

This could be a possible class blueprint. Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM