Tigraine

Daniel Hoelbling-Inzko talks about programming

Strange LinQ to SQL oddity

Posted by Daniel Hölbling on February 18, 2008

I'm still in the process of doing some research on the tools I'm going to use over the next weeks to build the Pizza.at web app.
So today I tried some LinQ to SQL so I can get used to it a bit. And while doing so I started out with reading through ScottGu's LinQ to SQL series.

I had already some parts of the database schema in place and so I imported it to the ORM, giving me the following model:

linq1

So, this all worked perfectly and I immediately started doing some select statements (while learning how to use and write Lambda expressions - I'll blog about this later).

linq2

And yippie! It worked, although I was very confused that this statement would return a InvalidOperationException in case the Lambda didn't return something. Although I like the fact that it returns an exception, I think the exception given here is too generic. They could have done better in giving the exception a stronger name.

But, after getting over the exception name, everything went smooth from there. Except for me not seeing one thing:
The C and D in CRUD!

ScottGu showed off in his series that doing a simple Categories.Add and an afterwards call to dbContext.SubmitChanges() should do.
In my version of Visual Studio and LinQ I simply don't find this method. All lists I get from the ORM are IQueryable and don't incorporate any Add and Delete Methods.

I'm getting a bit confused, I must be missing something at this point, there must be something I have overlooked. Any thoughts?

Filed under net, programmierung, job
comments powered by Disqus

My Photography business

Projects

dynamic css for .NET

Archives

more