ormlite-servicestack

ServiceStack MARS (Multiple Active Result Sets) using ORMLite and Output Parameters

南楼画角 提交于 2019-11-30 09:25:36
ServiceStack ORMLite is great, I've typically steered clear of the ORM mentality preferring to build databases as it makes sense to build databases instead of a 1:1 class model. That said, there are a couple of things that I seem to be running into difficulty around, I'm certain it's simply my ignorance shining through. First: Is there a way to manage multiple result sets using ORMLite? I know that one can use the QueryMultiple method using Dapper, but for whatever reason I'm having a bear of a time figuring out how to use the built-in Dapper implementation of ServiceStack. Second: Is there a

How to retrieve auto-incremented Id in ServiceStack OrmLite?

别等时光非礼了梦想. 提交于 2019-11-30 06:41:29
For a table that has an identity: [AutoIncrement] public int Id { get; set;} When inserting a new row into the database, what is the best way to retrieve the Id of the object? For example: db.Insert<> (new User()); The value of the Id is 0 after the insert, but in the database this obviously is not the case. The only possibility I can see is the following: Id = (int)db.GetLastInsertId(); However I don't believe this would be a safe call to make. If there are 100's of inserts happening at the same time, an Id for another insert may be returned. In EF when you do an insert the Id is set for you.

How do I join 2 tables in ServiceStack OrmLite and select both classes?

江枫思渺然 提交于 2019-11-30 05:33:02
问题 I'd like to do a simple SQL join in ServiceStack OrmLite and get both tables as the corresponding .NET objects. In LINQ-to-Entities it would be something like this: Claim.Join(Policy, c => c.PolicyId, p => p.Id, (c, p) => new { Claim = c, Policy = p }) This would give me an anonymous type with Claim and Policy properties. I've looked at the OrmLite Advanced Join Example, but that only selects some of the properties of each type into a 3rd type of object ( FullCustomerInfo ). I don't want to

Best practices of implementing unit of work and repository pattern using ServiceStack.ORMLite

☆樱花仙子☆ 提交于 2019-11-29 17:54:36
问题 Supposing that there are two repository interface : interface IFooRepository { void Delete(int id); } interface IBarRepository { void Delete(int id); } And an IUnitOfWork interface like : interface IUnitOfWork : IDisposable { void Commit(); void Rollback(); } what is the best practices of implementing those interface using ServiceStack.ORMLite so that user can use them like MyFooRepository.Delete(4); // if an Exception throws here, Bar won't be deleted MyBarRepository.Delete(7); Or using (var

ServiceStack benchmark continued: why does persisting a simple (complex) to JSON slow down SELECTs?

不问归期 提交于 2019-11-29 16:08:27
So, mythz didnt like my no-so-scientific benchmark question in a previous SO question, but since I would like to switch over to OrmLite, I need to figure out if it is slow, and if so, why. In my "research", I come to the conclusio that complex objects, that in OrmLite are blobbed to JSON, is the culprit of very slow SELECTs. Therefore, I created a new project that focuses solely on OrmLite, and does not compare with anything else other than itself, and the aim here is to see the differences between having blobbed JSON objects, and not having them. It can be found on GitHub: https://github.com

ServiceStack MARS (Multiple Active Result Sets) using ORMLite and Output Parameters

自闭症网瘾萝莉.ら 提交于 2019-11-29 15:12:58
问题 ServiceStack ORMLite is great, I've typically steered clear of the ORM mentality preferring to build databases as it makes sense to build databases instead of a 1:1 class model. That said, there are a couple of things that I seem to be running into difficulty around, I'm certain it's simply my ignorance shining through. First: Is there a way to manage multiple result sets using ORMLite? I know that one can use the QueryMultiple method using Dapper, but for whatever reason I'm having a bear of

Add property to POCO class at runtime

不打扰是莪最后的温柔 提交于 2019-11-29 10:08:41
I selected ServiceStack OrmLite for my project which is a pure Data-Oriented application. I am willing to allow the end user to create his own Object Types defined in an XML format that will be used to generate classes at runtime using CodeDOM . I will be also defining some "system" objects required by the application (i.e. User ) but I cannot foresee all the properties the end user will use and therefore I am looking for a way to allow extending the classes I create in design time. Sample bellow public class User { public Guid Uid { get; set; } public String Username { get; set; } public

How to register multiple IDbConnectionFactory instances using Funq in ServiceStack.net part 2

一曲冷凌霜 提交于 2019-11-29 08:48:55
ServiceStack has delivered on EVERYTHING I've thrown at it, except the SAAS (Multi-tenant) use case where single API instance is using several databases of the same schema, one per tenant. These databases, because of legal reasons need to be housed in separate instances. So, my question is this, "Is it possible to change the connection per Request based on meta from a filter? My question is somewhat similar to this one , but with the added twist that each database is the same. Thank you, Stephen Edit: If memory serves me correctly I think mythz and I have discussed this before and found that

How to retrieve auto-incremented Id in ServiceStack OrmLite?

随声附和 提交于 2019-11-29 05:54:10
问题 For a table that has an identity: [AutoIncrement] public int Id { get; set;} When inserting a new row into the database, what is the best way to retrieve the Id of the object? For example: db.Insert<> (new User()); The value of the Id is 0 after the insert, but in the database this obviously is not the case. The only possibility I can see is the following: Id = (int)db.GetLastInsertId(); However I don't believe this would be a safe call to make. If there are 100's of inserts happening at the

Many to many relations with ServiceStack.OrmLite

会有一股神秘感。 提交于 2019-11-29 00:15:40
I've been checking ServiceStack's documentation, but I haven't found a way to do many to many relationships with ServiceStack.OrmLite, is it supported? Is there a workaround (without writing raw sql)? I'd like to have something like this: Article <- ArticleToTag -> Tag Thanks!! It's not implicitly handled automatically for you behind the scenes if that's what you mean? But as OrmLite is just a thin wrapper around ADO.NET interfaces anything is possible. In OrmLite , by default every POCO maps 1:1 with a table. So if you wanted the table layout you would create it just as it looks in your