DataContext only ReadOnly

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
KKirchhoff
Posts: 14
Joined: Fri 03 Oct 2008 07:43

DataContext only ReadOnly

Post by KKirchhoff » Sat 12 Dec 2009 13:02

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]

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Mon 14 Dec 2009 08:41

Could you please describe the problem?
What exception are you getting?
Could you please post a code sample you are using to modify data?

aram
Posts: 9
Joined: Wed 03 Feb 2010 12:34

Post by aram » Wed 03 Feb 2010 12:43

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.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Wed 03 Feb 2010 13:56

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.

aram
Posts: 9
Joined: Wed 03 Feb 2010 12:34

Post by aram » Wed 03 Feb 2010 14:19

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

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Wed 03 Feb 2010 15:08

Thank you for sharing your solution. The scenario with Primary Key is a default LINQ behaviour.

aram
Posts: 9
Joined: Wed 03 Feb 2010 12:34

Post by aram » Wed 03 Feb 2010 15:33

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

Post Reply