Hello Team,
My Code is -
namespace Models
{
public class getChildQuestions
{
public int qid { get; set; }
public string qname { get; set; }
}
public class GetCPQuestionMasterModel
{
public List Child_Question_Get { get; set; }
return SubQuestions.ToList();
}
}
}-------------
{
public class getChildQuestions
{
public int qid { get; set; }
public string qname { get; set; }
}
public class GetCPQuestionMasterModel
{
public Int32 QID_Get { get; set; }
public List
public Int32 Active_Get { get; set; }
}
}
-----------------------------
namespace DAL
{
public static List SubQuestions(Int32 QuestionID)
{
CPContext Context = new CPContext();
}
-----------------------------
namespace DAL
{
public static List
{
CPContext Context = new CPContext();
var SubQuestions = (from CB in Context .Question_Master
where CB.FKQID == QuestionID
select new getChildQuestions
{
qid = CB.QID,
qname = CB.Question
});
where CB.FKQID == QuestionID
select new getChildQuestions
{
qid = CB.QID,
qname = CB.Question
});
return SubQuestions.ToList();
}
---------
public List GetQuestionMaster(GetCPModel _Req)
{
CPContext Context = new CPContext ();
public List
{
CPContext Context = new CPContext ();
List _resReponseModel = null;
Int32 QuestionMasterCount = Context.Question_Master.Count();
if (QuestionMasterCount > 0)
{
_resReponseModel = (from p in Context.Question_Master
select new GetCPModel
{
QID_Get = p.QID,
Child_Question_Get = SubQuestions(p.FKQID),
Active_Get = p.Active,
}).ToList();
Int32 QuestionMasterCount = Context.Question_Master.Count();
if (QuestionMasterCount > 0)
{
_resReponseModel = (from p in Context.Question_Master
select new GetCPModel
{
QID_Get = p.QID,
Child_Question_Get = SubQuestions(p.FKQID),
Active_Get = p.Active,
}).ToList();
}
return _resReponseModel ;
return _resReponseModel ;
}
}
On Line "Child_Question_Get = SubQuestions(p.FKQID), ", I am
I am getting an error -"Error in converting "how are you" to 'System.Collections.Generic.List`.
Please guide .. ITs really urgent.
Riddhi ValechaPosted Dec 14, 2020, 12:15 PM
Hello sir...
I am not getting how to bind this method... I need to get the output in controller - it is httpget method.
[Route("GetAdminQuestionMaster")]
[HttpGet]
public IActionResult GetAdminQuestionMaster(CPQuestionMasterModel _reqCPQuestionMasterModel)
{
Response responseGet = new Response();
var lstRecords = new CPQuestionMaster().GetQuestionMaster();
}
Riddhi ValechaPosted Dec 14, 2020, 9:28 AM
Hello sir.. I am again stuck up.. I am sharing my code -
{
[Key]
public Int32 QID { get; set; }
public string Question { get; set; }
---
public class GetQuestionMasterModel
{
public Int32 QID_Get { get; set; }
public string Parent_Question_Get { get; set; }
--------------
public List
{
return list.Where(x => x.ParentQuestionID_Get == FKQID).Select(x => new CP_Question_Master
{
QID_Get = x.QID_Get,
Parent_Question_Get = x.Parent_Question_Get,
Children = GetTree(list, x.QID_Get)
}).ToList();
}
-------------------------------
public List
{
Int32 QuestionMaster_Count = DBQuestionMasterContext.CP_Question_Master.Count();
if (QuestionMaster_Count > 0)
{
_resReponseQuestionMasterModel = (from p in DBQuestionMasterContext.Question_Master
where p.FKQID == 0
select new GetQuestionMasterModel
{
QID_Get = p.QID,
Children = GetTree(p.Children , p.FKQID),
}).ToList();
return _resReponseQuestionMasterModel;
}
Sachin SinghPosted Dec 14, 2020, 9:04 AM
Sachin SinghPosted Dec 14, 2020, 7:35 AM
Riddhi ValechaPosted Dec 14, 2020, 7:09 AM
Hello sir,
Could you please share the get;set properties of the class files ?
Riddhi ValechaPosted Dec 14, 2020, 2:34 AM
Sachin SinghPosted Dec 14, 2020, 12:44 AM
Riddhi ValechaPosted Dec 12, 2020, 12:19 PM
Sachin SinghPosted Dec 11, 2020, 10:19 AM
Riddhi ValechaPosted Dec 11, 2020, 4:12 AM
Hello Sir,
I will show the Database structure and the output that I need -
sub_question : "problem with"
{
Sub_ques_ques : driver
{
Sub_ques_ques_opt : driver rude,
Sub_ques_ques_opt : driving fast
},
Sub_ques_ques : car
{
Sub_ques_ques_opt : car dirty,
Sub_ques_ques_opt : car noisy
}
}
}
--
FKQID == 0 => parent_question
FKQID != 0 => sub_question
"problem with" is the sub_question of "Please rate"
"driver" and "car" are options for question "problem with"
"driver rude", "driving fast" are options for question "driver"
"car dirty" and "car noisy" are options for question "car"
-----
Riddhi ValechaPosted Dec 10, 2020, 12:51 PM
Hello sir,
Sachin SinghPosted Dec 10, 2020, 9:33 AM