.NET Questions (CLOSED)

Questions and Answers on any aspect of .NET. Now closed.

This discussion group is now closed.

Have a question about .NET development? Try stackoverflow.com, a worldwide community of great developers asking and answering questions 24 hours a day.

The archives of .NET Questions contain years of Q&A. Even older .NET Questions are still online, too.

Creating a WCF Database service

So I'd like to host a database service. It's a simple service - just a SQLite database i want at the server side.

Thus, my service class looks like:

[ServiceContract]
public class DatabaseService
{
    SQLiteConnection connection;

//methods for read-write operations
}

However, when i try to add this as a service reference, it gives me an error stating that SQLiteConnection should be serialized.

This made me think - maybe i'm thinking about how to go about creating databases services all wrong? Do you have any ideas on how to design something as simple as this?

Is this a problem particular to SQlite?
Shiny Happy Send private email
Saturday, January 26, 2008
 
 
You didn't show the code for your read/write operation contracts, but I'm guessing that you're trying to pass a Connection or a Command object as a parameter. That's not something that should be passed into or out of a service.

What you really want to do is to serialize your query requests and responses. So, you have to have your own set of structures to do it properly. You can even serialize LINQ queries if you want to, (see http://www.codeplex.com/interlinq).

Also, this forum isn't the best place for a WCF question, you'll get better results in the Microsoft Forums for WCF/Indigo, here - http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=118&SiteID=1
Wayne Bloss Send private email
Sunday, January 27, 2008
 
 
Also, keep in mind that WCF is relatively new and there are very few examples on the Net for your particular problem.

So, just be prepared to spend some time learning about the inner workings of WCF and really thinking about your design.
Wayne Bloss Send private email
Sunday, January 27, 2008
 
 
The class that implements your service should normally open and close a connections each time it accesses the database.  Therefore it doesn't make sense to have the connection as a member field.
Joe
Sunday, January 27, 2008
 
 
The WCF data serializer wont know anything about a non-framework entity like SQLiteConnection by default!
jonathan
Monday, January 28, 2008
 
 
yeah, so i think you need to decorate your type using [DataContract] etc...in order to push it on the wire.
jonathan
Monday, January 28, 2008
 
 
Hey guys - thanks for all the tips, very helpful.

As for the code sample above, it was very simple - just some attribute issues - wrong decoration.

Thanks!
Shiny Happy Send private email
Thursday, January 31, 2008
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz