如何连接Raven Db数据库并执行CRUD操作 [英] How to connect Raven Db database and perform CRUD operation

查看:107
本文介绍了如何连接Raven Db数据库并执行CRUD操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我想在mvc 4 asp.net中创建一个应用程序但是有些问题就像连接raven db create document,update,edit,delete











联系上课

Hi All,

I want make one application in mvc 4 asp.net but some issue occurred like connect raven db create document , update ,edit ,delete





contact is class

public class Contact
    {
        public string Id { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public DateTime DateOfBirth { get; set; }
        public string Address { get; set; }
        public string City { get; set; }
 }



用于创建和连接数据库


for create and connect database

documentStore = new DocumentStore { Url = "http://localhost:8085/" };
                documentStore.Initialize();


                using (var session = documentStore.OpenSession())
                {
                    session.Store(contact);
                    session.SaveChanges();
                }





但是在raven db中输入数据库



But does entry in database in raven db

推荐答案

RavenDB是基于.NET的,因此您应该能够在.NET中与它进行交互。如果它是基于SQL的,您应该能够创建连接字符串并使用ODBC类。如果不是,您将需要使用他们提供的方法来访问它。



http://ravendb.net/learn [ ^ ]是链接学习如何使用它。
RavenDB is .NET based, so you should be able to interact with it in .NET. If it's SQL based, you should be able to create a connection string and use the ODBC classes. If it's not, you'll need to use the methods they provide to access it.

http://ravendb.net/learn[^] is the link to learn how to use it.


用于初始化ravendb服务器



var documentStore = new DocumentStore {ConnectionStringName =RavenDB} ;

documentStore.Initialize();



使用(var session = documentStore.OpenSession(TEST))

{

session.Store(ravendata,templateName);

session.Advanced.GetMetadataFor(ravendata)[Constants.RavenEntityName] =Template;

session.SaveChanges();

}



用于保存在数据库中
For initialize ravendb server

var documentStore = new DocumentStore { ConnectionStringName = "RavenDB" };
documentStore.Initialize();

using (var session = documentStore.OpenSession("TEST"))
{
session.Store(ravendata, templateName);
session.Advanced.GetMetadataFor(ravendata)[Constants.RavenEntityName] = "Template";
session.SaveChanges();
}

For save in database


这篇关于如何连接Raven Db数据库并执行CRUD操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆