servicestack

ServiceStack ORMLite Cannot Update Identity Column

余生长醉 提交于 2020-01-05 05:47:12
问题 I am using ServiceStack ORMLite to try and update a record in my database. All of my POCO's implement an IHasID interface public interface IHasId { int Id { get; set; } } In my POCO I have the following property private int id; [ServiceStack.DataAnnotations.Alias("TableName_ID")] public int Id { get { return id; } set { if (value != this.id) { this.id = value; NotifyPropertyChanged("Id"); } } } Each of my repository classes inherits a from a DataRepositoryBase< T> class that has the following

Can I make ServiceStack Deserialize json value of 1 as true?

馋奶兔 提交于 2020-01-05 04:33:12
问题 Can I make ServiceStack Deserialize json value of 1 as true? Here's a unit test showing what I want to do. Is this possible? if so how? public class Foo { public bool isWorking { get; set; } } ... [Test] public void Deserialise1AsBoolean() { var json = @"{""isWorking"": 1}"; var myFoo = json.FromJson<Foo>(); Assert.IsTrue(myFoo.isWorking); } 回答1: This is now built into ServiceStack.Text with this commit available from v3.9.55+. 回答2: EDIT Here's my solution, but please check out Mythz as well

Serving default index.html page when using Angular HTML5mode and Servicestack on the backend

心已入冬 提交于 2020-01-04 23:21:34
问题 I am new to ServiceStack and Angular. Apologies if this is verbose. with reference to Html5 pushstate Urls on ServiceStack I would like to be able to have my api service served up from the root. ie http://mydomain.com/ If a user browses the route, I would like to serve up a default html page that bootstraps my angular app. In the the app itself if angular calls mydomain.com/customer/{id} json should be served but if this is browsed directly it should serve the default html page and keep the

re-using ServiceStack validation in Winforms offline client

喜你入骨 提交于 2020-01-04 15:15:54
问题 We have a working website using ServiceStack as the back end that amounts to a complex data-entry form. My users have requested an "offline editor" for the forms. To use the offline program, the user will have to connect to the ServiceStack service, create empty instances of the forms, and then I will save the POCOs from the service to disk using ServiceStack's JSON serializer. From there the user can log off the service and edit the POCOs. When they're done, they reconnect to the service,

How to return nested objects of many-to-many relationship with autoquery

亡梦爱人 提交于 2020-01-04 14:12:38
问题 Lets say I have 3 classes: public class Book { [Autoincrement] public int Id {get; set;} public string Title {get; set;} [Reference] public list<BookAuthor> BookAuthors {get; set;} } public class BookAuthor { [ForeignKey(typeof(Book))] public int BookId {get; set;} [Reference] public Book Book {get; set;} [ForeignKey(typeof(Author))] public int AuthorId {get; set;} [Reference] public Author Author {get; set;} } public class Author { [Autoincrement] public int Id {get; set;} public string Name

How to return nested objects of many-to-many relationship with autoquery

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-04 14:12:09
问题 Lets say I have 3 classes: public class Book { [Autoincrement] public int Id {get; set;} public string Title {get; set;} [Reference] public list<BookAuthor> BookAuthors {get; set;} } public class BookAuthor { [ForeignKey(typeof(Book))] public int BookId {get; set;} [Reference] public Book Book {get; set;} [ForeignKey(typeof(Author))] public int AuthorId {get; set;} [Reference] public Author Author {get; set;} } public class Author { [Autoincrement] public int Id {get; set;} public string Name

ServiceStack.Redis: Unable to Connect: sPort:

久未见 提交于 2020-01-04 04:29:06
问题 I regularly get ServiceStack.Redis: Unable to Connect: sPort: 0 or ServiceStack.Redis: Unable to Connect: sPort: 50071 (or another port number). This appears to happen when our site is busier. Redis itself appears fine, no real increase in CPU or memory usage. I'm using connection pooling and have tried changing the timeout values without success. public sealed class RedisConnection { // parameter values are: // Config.Settings.RedisPoolSize = 10000 // Config.Settings.RedisPoolTimeoutSeconds

Using Linq2Twitter and cached OAuth tokens withing a ServiceStack api

╄→尐↘猪︶ㄣ 提交于 2020-01-04 04:16:15
问题 I want to use Linq2Twitter to make a Twitter API call from within a REST API written in ServiceStack. I have the following information: ConsumerKey ConsumerSecret cached OAuth Token from when the user authenticated our app on the site cached OAuth TokenSecret from when the user authenticated our app on the site How do I create the TwitterContext using this information so that I can make API calls? I am looking at the documentation and I see WebForm, MVC, Desktop examples, but none for my

Servicestack Options 404 and Cors Origin

左心房为你撑大大i 提交于 2020-01-04 02:12:11
问题 I am doing a cors request from my client: http://mypcname.companyname to the servicestack server: http://mypcname.companyname:83/customersInformation Thats the request with javascript superagent library: superagent.get(requestUrl) .set('Authorization', "basictoken " + getToken()) .set('Accept', 'application/json') .end(function (response) { }); This get request works totally fine with the Web API ! So the problem can not be the client side in my opinion. Thats my service stack setup: Plugins

ServiceStack AutoQuery synthetic field

。_饼干妹妹 提交于 2020-01-04 01:38:09
问题 In the Northwind example's Customer DTO there is a field Email that is synthetic -- i.e. it doesn't come from the database. Code here: https://github.com/ServiceStackApps/Northwind/blob/master/src/Northwind/Northwind.ServiceModel/Types/Customer.cs But when viewing this in the running example, this field is not visible: http://northwind.servicestack.net/query/customers I've noticed this DTO has [DataContract] and [DataMember] annotations, whereas most other examples do not. How do I add