views:

438

answers:

4

Hi, I would like to use some kind of nosql database in my web application which is written in asp.net mvc , but cannot find anything useful. I have a looked at MongoDB and CouchDB but i'd like to have better api (strongly typed not magic strings) for my queries than they have. Is anything like this exists for .NET ?

+1  A: 

MongoDB doesn't use magic strings, but uses query documents to represent queries. There is also an open source C# driver available. I'm not sure of the specifics of the C# driver, but it should be relatively easy to add a validation layer on top of it if one doesn't exist already. There are similar projects on top of the drivers in Python and Ruby, for example.

mdirolf
Yeah, but tell me please how to save and retreive my domain object in type safe manner?
Tadeusz Wójcik
i'm not sure exactly what you're looking for when you say "type safety". i think the best you could do is use a database access layer that handles validating the data you're saving to and getting out of MongoDB.
mdirolf
A: 

You can connect to text files using ADO.NET and read/write them using SQL syntax and Commands issued through ADO.NET. There's an example in this article. Your data will be stored in human-readable format in comma- or tab-delimited record format. Of course it won't be fast with large data sets. I'm unsure if you're trying to get away from both SQL databases and SQL syntax. The text file solutions is queryable by SQL.

You can also do the same with Excel spreadsheets by treating them like SQL data sources (even though they're not) through ADO.NET access.

John K
+1  A: 

Not sure if it is what you are looking for but you could try http://www.db4o.com/ I've never used it myself but it may help you

CriGoT
+2  A: 

I'm the principle author behind the .Net driver for Mongo. There isn't currently a ORM like mapper for it yet. Instead it works on simple documents that are the equivalent of a dictionary. It wouldn't be hard to use reflection to iterate over the fields in a document and assign them to properties on an object. I've written a simple thing like that for LDAP results in the past. You don't have to worry about sql injection with Mongo as there really isn't a query language that gets parsed. All drivers talk to Mongo in its native tongue. There is some potential if you dynamically generate javascript and send it to the DB but the need for that should mostly be rare. If you have any questions about using the driver feel free to post them to the Google Group or send a message through GitHub.

Sam Corder
Hi ,I've decided to use mongo in my project , but I don't know how to nest some object in my document, let's say i have question document and want to have answers in it , but have no idea how to do this
Tadeusz Wójcik
Embedded documents are just attributes on a containing document. Here is a one liner. You can certainly separate it out on multiple lines if need be.Document doc = new Document().Append("embeddedDoc", new Document().Append("attr1","val1"));
Sam Corder
Ok, but is it possible to add collection of documents , let's say I have question and want have collection of answers for it, when i tried do this i had exception becouse key answers already exist
Tadeusz Wójcik
Send me a message on GitHub with the code you are trying to do or post it to the mongodb-user Google group.
Sam Corder
Does Mongo only works as dictionary. I mean what if I have a User class with FirstName and LastName properties.
azamsharp