Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 605779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:10:58+00:00 2026-05-13T17:10:58+00:00

I’m trying to get my brain wraped around Silverlight RIA I’m to a point

  • 0

I’m trying to get my brain wraped around Silverlight RIA

I’m to a point where I can create an object with a collection of objects which also has a collection of objects.

Test object that holds test questions, that holds question answers.

I have the associations set up and the the data makes it to to silverlight app.

So in my loaded callback….i can see all the data in up

   private void TestLoaded(LoadOperation lo)
    {
            var ce =dc.Tests.CanEdit;
            dc.Tests.ToList()[0].TestQuestions.ToList()[0].StudentAnswerID = 2;
    }

var ce =dc.Tests.CanEdit; //CanEdit = true

but the next line gives the error:
This EntitySet of type ‘SilverlightApplication2.Web.Question’ does not support the ‘Edit’ operation.

So my question is why does CanEdit = true?
And what is a more graceful way of setting the value in code behind?

rest of the code…..

        public class Test
    {
        private List<Question> _testQuestions = new List<Question>();

        [Key]
        public int TestID { get; set; }

        public string TestName { get; set; }


        [Include]
        [Association("Assoc1", "TestID", "TestID,QuestionID")]
        public List<Question> TestQuestions
        {
            get { return _testQuestions; }
            set { _testQuestions = value; }
        }
    }


    public class Question
    {
        private List<Answer> _questionAnswers = new List<Answer>();

        [Key]
        public int TestID { get; set; }

        [Key]
        public int QuestionID { get; set; }

        public string QuestionText { get; set; }

        public int CorrectAnswerID { get; set; }
        public int StudentAnswerID { get; set; }

        [Include]
        [Association("Assoc2", "QuestionID", "QuestionID,AnswerID")]
        public List<Answer> QuestionAnswers
        {
            get { return _questionAnswers; }
            set { _questionAnswers = value; }
        }
    }



    public class Answer
    {
        [Key]
        public int QuestionID { get; set; }

        [Key]
        public int AnswerID { get; set; }

        public string AnswerText { get; set; }
    }

//data populator

 public class TestBuilder
{

    public List<Test> MakeATest()
    {
        var ret = new List<Test>();

        var t = new Test()
        {
            TestID = 1,
            TestName = "The Test",
        };

        var tq = new Question() { TestID = 1, QuestionID = 1, CorrectAnswerID=1,  QuestionText = "T1Q1" };

        var a = new Answer() { QuestionID = 1, AnswerID = 1, AnswerText = "T1Q1A1" };
        tq.QuestionAnswers.Add(a);

        a = new Answer() { QuestionID = 1, AnswerID = 2, AnswerText = "T1Q1A2" };
        tq.QuestionAnswers.Add(a);

        a = new Answer() { QuestionID = 1, AnswerID = 3, AnswerText = "T1Q1A3" };
        tq.QuestionAnswers.Add(a);

        a = new Answer() { QuestionID = 1, AnswerID = 4, AnswerText = "T1Q1A4" };
        tq.QuestionAnswers.Add(a);
        t.TestQuestions.Add(tq);


        //second question
        tq = new Question() { TestID = 1, QuestionID = 2, CorrectAnswerID = 3, QuestionText = "T1Q2" };

        a = new Answer() { QuestionID = 2, AnswerID = 1, AnswerText = "T1Q2A1" };
        tq.QuestionAnswers.Add(a);

        a = new Answer() { QuestionID = 2, AnswerID = 2, AnswerText = "T1Q2A2" };
        tq.QuestionAnswers.Add(a);

        a = new Answer() { QuestionID = 2, AnswerID = 3, AnswerText = "T1Q2A3" };
        tq.QuestionAnswers.Add(a);

        a = new Answer() { QuestionID = 2, AnswerID = 4, AnswerText = "T1Q2A4" };
        tq.QuestionAnswers.Add(a);
        t.TestQuestions.Add(tq);


        //third question
        tq = new Question() { TestID = 1, QuestionID =3, CorrectAnswerID = 4, QuestionText = "T1Q3" };

        a = new Answer() { QuestionID = 3, AnswerID = 1, AnswerText = "T1Q3A1" };
        tq.QuestionAnswers.Add(a);

        a = new Answer() { QuestionID = 3, AnswerID = 2, AnswerText = "T1Q3A2" };
        tq.QuestionAnswers.Add(a);

        a = new Answer() { QuestionID = 3, AnswerID = 3, AnswerText = "T1Q3A3" };
        tq.QuestionAnswers.Add(a);

        a = new Answer() { QuestionID = 3, AnswerID = 4, AnswerText = "T1Q3A4" };
        tq.QuestionAnswers.Add(a);
        t.TestQuestions.Add(tq);

        ret.Add(t);

        return ret;
    }
}

Domain Service…..

 [EnableClientAccess()]
public class TestDomainService : DomainService
{
    public IEnumerable<Test> GetTest()
    {
        var tb = new TestBuilder();
        return tb.MakeATest();
    }

    public void InsertTest(Test currentData)
    {}

    public void UpdateTest(Test currentData)
    {}

    public void DeleteTest(Test currentData)
    {}
}

Silverlight side……

      private void GetTest_Click(object sender, RoutedEventArgs e)
    {
        dc.Load(dc.GetTestQuery(),
                LoadBehavior.RefreshCurrent ,
                TestLoaded,
                null);
    }


    private void TestLoaded(LoadOperation lo)
    {
            var ce =dc.Tests.CanEdit;
            dc.Tests.ToList()[0].TestQuestions.ToList()[0].StudentAnswerID = 2;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T17:10:59+00:00Added an answer on May 13, 2026 at 5:10 pm

    Why are you calling ToList()? RIA returns an EntitySet which inherits from IEnumerable so you shouldnt need to put it in a list. I would suggest trying a linq statement like:

    using System.Linq;
    Test mytest = dc.Tests.Where( x=> x.StudentAnswerID = 2).FirstorDefault();
    

    As to the editing problem… If you are using Entity Framework as your data model be sure to check the checkbox “enable editing” when you create your domain service. CanEdit is a readonly value that tells you whether or not editing is allowed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to select an H1 element which is the second-child in its group
I'm trying to create an if statement in PHP that prevents a single post
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.