MongoDB用于c#和iPhone应用程序

时间:2022-07-20 03:01:47

I'm in the initial phase of designing an application that will have a backend implemented in C# that will provide data for other platforms using WCF web services hosted on IIS. One of the platforms will the the iPhone.

我正在设计一个应用程序的初始阶段,该应用程序的后端将在c#中实现,使用IIS上的WCF web服务为其他平台提供数据。其中一个平台将是iPhone。

Since it's a personal project, I want to use it to learn MongoDB. I already know that there are community developed drivers for MongoDB and C#, so I could handle the persistence on the server side using MongoDB.

因为这是一个个人项目,所以我想用它来学习MongoDB。我已经知道有社区开发的MongoDB和c#驱动程序,所以我可以使用MongoDB来处理服务器端上的持久性。

Without even knowing the replications models offered by MongoDB, I was thinking about some kind of simple synchronization model to keep data local if the iPhone is not connected or has a poor connection.

我甚至不知道MongoDB提供的复制模型,而是在考虑某种简单的同步模型,以便在iPhone没有连接或连接不好的情况下保持数据本地。

Here's the question: Can MongoDB be used in the iPhone using the MongoDB C drivers? Has anybody already tried that?

问题是:MongoDB能在iPhone中使用MongoDB C驱动程序吗?有人试过吗?

1 个解决方案

#1


4  

The typical iPhone architecture is to have your application call out to a web service. Even if it is possible to use a MongoDB driver directly from a mobile client I would not recommend it. For a few reasons.

典型的iPhone架构是让应用程序调用web服务。即使可以直接从移动客户端使用MongoDB驱动程序,我也不会推荐它。几个原因。

You are basically talking about doing client server architecture where your client application talks directly to the datastore (MongoDB.) What about security? When any authenticated client talks directly to the datastore all sorts of bad things can happen.

您主要讨论的是客户端服务器体系结构,其中客户端应用程序直接与数据存储(MongoDB)对话。安全呢?当任何经过身份验证的客户端直接与数据存储进行对话时,都会发生各种糟糕的事情。

Tightly coupling your client application directly to any given data access technology is dangerous in that it would require you to rewrite your client if for some reason you needed to change your data access solution.

将客户端应用程序直接与任何给定的数据访问技术紧密耦合是危险的,因为如果出于某种原因需要更改数据访问解决方案,就需要重写客户端。

It is more common these days to have your client applications go through a data access tier and when the Internet is involved this tier often involves a web service of some sort unless you want to get elbows deep writing server code.

现在,让客户端应用程序通过数据访问层变得更加常见,当涉及到Internet时,这一层通常涉及某种web服务,除非您希望深入编写服务器代码。

Think about writing a RESTful api exposing your datastore to your iPhone client. I've heard good things about Open Rasta (C# REST library)

考虑编写一个RESTful api,将您的数据存储公开到您的iPhone客户端。我听说过Open Rasta (c# REST库)

Edit - More about hosting MongoDB on the iPhone

编辑-更多关于在iPhone上托管MongoDB。

Sorry I didn't understand that you wish to run MongoDB locally on iPhone. MongoDB is a server. I do not believe that it is embeddable as an in-process datastore. And it is not possible to run more than one process on the iPhone.

对不起,我不明白你想在iPhone上本地运行MongoDB。MongoDB是一个服务器。我不认为它可以作为进程内的数据存储嵌入。在iPhone上运行多个进程是不可能的。

If you are familiar with C# you might want to check out MonoTouch. It allows you to run C# applications on iPhone. There is a nice library for using SqlLite which is supported by iPhone.

如果您熟悉c#,您可能想要查看MonoTouch。它允许你在iPhone上运行c#应用程序。有一个很好的库用于使用iPhone支持的SqlLite。

#1


4  

The typical iPhone architecture is to have your application call out to a web service. Even if it is possible to use a MongoDB driver directly from a mobile client I would not recommend it. For a few reasons.

典型的iPhone架构是让应用程序调用web服务。即使可以直接从移动客户端使用MongoDB驱动程序,我也不会推荐它。几个原因。

You are basically talking about doing client server architecture where your client application talks directly to the datastore (MongoDB.) What about security? When any authenticated client talks directly to the datastore all sorts of bad things can happen.

您主要讨论的是客户端服务器体系结构,其中客户端应用程序直接与数据存储(MongoDB)对话。安全呢?当任何经过身份验证的客户端直接与数据存储进行对话时,都会发生各种糟糕的事情。

Tightly coupling your client application directly to any given data access technology is dangerous in that it would require you to rewrite your client if for some reason you needed to change your data access solution.

将客户端应用程序直接与任何给定的数据访问技术紧密耦合是危险的,因为如果出于某种原因需要更改数据访问解决方案,就需要重写客户端。

It is more common these days to have your client applications go through a data access tier and when the Internet is involved this tier often involves a web service of some sort unless you want to get elbows deep writing server code.

现在,让客户端应用程序通过数据访问层变得更加常见,当涉及到Internet时,这一层通常涉及某种web服务,除非您希望深入编写服务器代码。

Think about writing a RESTful api exposing your datastore to your iPhone client. I've heard good things about Open Rasta (C# REST library)

考虑编写一个RESTful api,将您的数据存储公开到您的iPhone客户端。我听说过Open Rasta (c# REST库)

Edit - More about hosting MongoDB on the iPhone

编辑-更多关于在iPhone上托管MongoDB。

Sorry I didn't understand that you wish to run MongoDB locally on iPhone. MongoDB is a server. I do not believe that it is embeddable as an in-process datastore. And it is not possible to run more than one process on the iPhone.

对不起,我不明白你想在iPhone上本地运行MongoDB。MongoDB是一个服务器。我不认为它可以作为进程内的数据存储嵌入。在iPhone上运行多个进程是不可能的。

If you are familiar with C# you might want to check out MonoTouch. It allows you to run C# applications on iPhone. There is a nice library for using SqlLite which is supported by iPhone.

如果您熟悉c#,您可能想要查看MonoTouch。它允许你在iPhone上运行c#应用程序。有一个很好的库用于使用iPhone支持的SqlLite。