servicestack

ServiceStack / ORM Lite - Foreign Key Relationships

隐身守侯 提交于 2020-01-01 16:21:47
问题 I have the following POCO: [Alias("Posts")] public class Post : IReturn<Post> { [AutoIncrement] [PrimaryKey] public int PostId { get; set; } public DateTime CreatedDate { get; set; } [StringLength(50)] public string CreatedBy { get; set; } [StringLength(75)] public string Title { get; set; } public string Body { get; set; } public int UpVote { get; set; } public int DownVote { get; set; } public bool IsPublished { get; set; } public List<Comment> Comments { get; set; } public List<Tag> Tags {

ServiceStack Selfhosted Application Restart

对着背影说爱祢 提交于 2020-01-01 13:29:36
问题 How can I restart a ServiceStack self hosted Apphost? Setting my AppHost instance to null and disposing of it does not work correctly, it throws the following Exception: System.ArgumentException: An entry with the same key already exists. I need to be able to do this to reload settings and start the AppHost without restarting the Windows Service hosting the AppHost EDIT: Scott and Moo-Juice's suggestions to run the AppHost in a different AppDomain is the correct solution. In order to get past

ServiceStack Authentication with Existing Database

梦想的初衷 提交于 2020-01-01 10:59:28
问题 I've been looking at ServiceStack and I'm trying to understand how to use BasicAuthentication on a service with an existing database. I would like to generate a public key (username) and secret key (password) and put that in an existing user record. The user would then pass that to the ServiceStack endpoint along with their request. What do I need to implement in the ServiceStack stack to get this working? I have looked at both IUserAuthRepository and CredentialsAuthProvider base class and it

Transactions in the Repository Pattern using ServiceStack.ORMLite

試著忘記壹切 提交于 2020-01-01 09:00:43
问题 I'm implementing Repository Pattern using ServiceStack.ORMLite like this: public class MyRepository : IMyRepository { private IDbConnectionFactory DbConnectionFactory = null; public MyRepository(IDbConnectionFactory dbConnectionFactory) { DbConnectionFactory = dbConnectionFactory; } public void MyMethod() { using (var connection = DbConnectionFactory.OpenDbConnection()) using (var cmd = connection.CreateCommand()) { //Do something here } } } But I don't know how to handle DbTransaction when I

Transactions in the Repository Pattern using ServiceStack.ORMLite

a 夏天 提交于 2020-01-01 09:00:11
问题 I'm implementing Repository Pattern using ServiceStack.ORMLite like this: public class MyRepository : IMyRepository { private IDbConnectionFactory DbConnectionFactory = null; public MyRepository(IDbConnectionFactory dbConnectionFactory) { DbConnectionFactory = dbConnectionFactory; } public void MyMethod() { using (var connection = DbConnectionFactory.OpenDbConnection()) using (var cmd = connection.CreateCommand()) { //Do something here } } } But I don't know how to handle DbTransaction when I

Use ASP.NET Membership in ServiceStack

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-01 05:37:05
问题 how can i use asp.net membership in ServiceStack ? (ServiceStack.OrmLite , ServiceStack.Host.AspNet , etc ) 回答1: You can host ServiceStack on a custom path, i.e. at /api which lets you run ASP.NET web forms and ServiceStack side-by-side and then use the normal ASP.NET membership provider in ASP.NET. You can then share UserSessions with ServiceStack using its Session Provider, here's an example on how to instantiate a Session with MVC - you can use this same class with ASP.NET. The alternative

Redis简单本机测试

匆匆过客 提交于 2020-01-01 05:09:59
下载Redis的windows 版本,里面包含32bit和64bit2个文件夹,和其他文件,根据系统选择拷贝32bit或者64bit的目录里面的文件到D:\redis文件夹里面,然后通过cmd命令进入到该文件,执行Redis-Server.exe Redis.conf启动服务端。 如果出现如下内容,及服务端启动成功:(注意服务端的Cmd窗口不能关闭,一旦关闭服务就停止了) d:\redis>redis-server.exe redis.conf [9340] 09 Dec 22:13:37 * Server started, Redis version 2.4.2 [9340] 09 Dec 22:13:37 * DB loaded from disk: 0 seconds [9340] 09 Dec 22:13:37 * The server is now ready to accept connections on port 6 379 在开启一个Cmd命令窗口启动客户端,出现以下就成功了。 d:\redis>redis-cli.exe -h 127.0.0.1 -p 6379 redis 127.0.0.1:6379> set pwd 123456 OK redis 127.0.0.1:6379> get pwd "123456" redis 127.0.0.1:6379>

What are the benefits of async webservices when not all parts of the code is async

梦想的初衷 提交于 2020-01-01 05:08:26
问题 I am wondering how much benefit you get from using async http requests if not all parts of your code is async. Lets consider to scenarios: 1) async http requests blocking on sync database calls, and 2) sync http requests awaiting async database calls. 1) Web Api supports async action methods, but if I do a sync database call when handling the request, then the thread blocks on the call, and I will not get the benefits of better thread economy that async could give me or what? 2) If I have a

With OrmLite, is there a way to automatically update table schema when my POCO is modified?

[亡魂溺海] 提交于 2020-01-01 05:08:13
问题 Can OrmLite recognize differences between my POCO and my schema and automatically add (or remove) columns as necessary to force the schema to remain in sync with my POCO? If this ability doesn't exist, is there way for me to query the db for table schema so that I may manually perform the syncing? I found this, but I'm using the version of OrmLite that installs with ServiceStack and for the life of me, I cannot find a namespace that has the TableInfo classes. 回答1: No there is no current

ServiceStack support for conditionally omitting fields from a REST response on a per-call basis

我的未来我决定 提交于 2019-12-31 23:12:07
问题 <TL;DR> At a minimum, I'm looking for a way to conditionally exclude certain properties on the resource from being included in the response on a per-call basis (See fields below). Ideally, I'd like to implement a REST service with ServiceStack that supports all the major points below. UPDATE While I really like ServiceStack's approach in general and would prefer to use it if possible, if it isn't particularly well suited towards these ideas I'd rather not bend over backwards bastardizing it