0

I made a method addquestion that calls addobject() and savechanges()

the Code inside the method is following:

public class AdminRepository
{
    Model1Container db = new Model1Container();
    CreateViewModel rep = new CreateViewModel();

    public void Question addquestion() // <-- I dont know how the method should be
    {
        Question q = new Question();

        q.QuestionText = rep.QuestionText;

        db.Question.AddObject(q);
        db.SaveChanges();
    }

I know that the code is right but I dont know how to define the method.

Thanks in advance!

Best Regards!

2 Answers 2

0

You are specifying both a return type of void and Question

Since you aren't actually returning anything inside your method, the correct return type is void

public void addquestion()
{
   //Your code here
}
0
public void AddQuestion()
{
    ....
}

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.