Page 1 of 1

DataContext only ReadOnly

Posted: Sat 12 Dec 2009 13:02
by KKirchhoff
Hi;
I have create a LinqToSQL-Model with the Entry Delveloper and my problen is, that i can´t change Data. I have no Problem to Read the Data !


Fox Example:

Code: Select all

var qry = from user in myDataContext.AppUser
     select new  
    {
       user.Id,
       user.Name
     }

myGrid.DataSource = qry;

Thx for Help[/code][/quote]

Posted: Mon 14 Dec 2009 08:41
by AndreyR
Could you please describe the problem?
What exception are you getting?
Could you please post a code sample you are using to modify data?

Posted: Wed 03 Feb 2010 12:43
by aram
AndreyR wrote:Could you please describe the problem?
What exception are you getting?
Could you please post a code sample you are using to modify data?
Hello, Since i have the same problem i will provide more details in this issue.

My code is:

Code: Select all

Bimstudentcontext.Bimstudentdatacontext context = new Bimstudentcontext.Bimstudentdatacontext();

Bimstudentcontext.Enumeration en=new Bimstudentcontext.Enumeration();
            en.Code = 10;
            en.En = "Test";
            en.Tr = "ıüğçöş"; // this is some unicode character
            context.Enumerations.InsertOnSubmit(en);
            context.SubmitChanges();
and the error i get on InsertOnSubmit line is
InvalidOperationException was unhandeled
Can't perform Create, Update or Delete operations on 'Table(Enumeration)' because it is read-only or does not have identity member.


and also when i try to update some record:

Code: Select all

 Bimstudentcontext.Bimstudentdatacontext context = new Bimstudentcontext.Bimstudentdatacontext();

            var enumerations = from v in context.Enumerations
                               where v.Code == 2
                               select v;
            foreach (var v in enumerations)
            {
                if (v.Code == 2)
                    v.Tr = "TESTING";
            }

            context.SubmitChanges();
it does not change the database.

I also get ORA-00933 twice on entity developer when using the database reverse engineering wizard.

My oracle version is: 8.1

Please help,
Thanks.

Posted: Wed 03 Feb 2010 13:56
by AndreyR
Judging from your connection string in the other post, both problems can be associated with Unicode characters.
Please set the unicode connection string parameter to true.
Please let me know if this doesn't help.

Posted: Wed 03 Feb 2010 14:19
by aram
AndreyR wrote:Judging from your connection string in the other post, both problems can be associated with Unicode characters.
Please set the unicode connection string parameter to true.
Please let me know if this doesn't help.
Thank you for your reply,

I pressed the advanced button in the wizard of entity developer and selected the unicode.

I still get the ora-00933 error.

And about the read only error I was getting earlier. It seems you queries do not work if a table does not have a primary key.
So I set one of the fileds to primary key and it is performing the insert and update perfectly.

So for those of you who still get readonly error, if you can, make one of the fieds as primary key and see if it works.

Best Regards,
Aram

Posted: Wed 03 Feb 2010 15:08
by AndreyR
Thank you for sharing your solution. The scenario with Primary Key is a default LINQ behaviour.

Posted: Wed 03 Feb 2010 15:33
by aram
AndreyR wrote:Thank you for sharing your solution. The scenario with Primary Key is a default LINQ behaviour.
Thanks,
That is good to know.

Aram