ormlite-servicestack

ServiceStack ORMLite - How to Select All to match the request DTO's properties automatically

↘锁芯ラ 提交于 2019-12-11 13:54:35
问题 I have several ServiceStack ORMLite POCO, one is Company below. public class Company { [AutoIncrement] public int id { get; set; } public string company { get; set; } public int? companyNo { get; set; } public bool? active { get; set; } } If two properties are valid in the following request: req.company="ABC Company", req.active=ture, and all other properties are null. Then it can return all records matching the two properties. The code may look like below: public object Get(Company req) {

ServiceStack OrmLite mapping with references not working

。_饼干妹妹 提交于 2019-12-11 08:45:24
问题 I'm trying out OrmLite to see if I can replace Entity Framework in my projects. The speed is quite significant on simple queries. But I tried to map/reference a [1 to many- relation and read the documentation + examined the test code from the github page but without success. This is my example. Is there something I've forgot or should do to get it working like Entity Framework? Example // EF: returns +15.000 records + mapped > product.StockItems (slow) dbContext.Products.Include(x => x

ServiceStack: Attribues for indexes not working?

末鹿安然 提交于 2019-12-11 07:41:06
问题 I am trying to use the attributes in ServiceStack.DataAnnotations to mark the properties in my POCOs so that the tables have the correct indexes, but it does not seem to work. My POCO: public class AlfaTo { [ServiceStack.DataAnnotations.Index(Unique = true)] [ServiceStack.DataAnnotations.AutoIncrement] public long id { get; set; } [ServiceStack.DataAnnotations.Index(Unique = false)] public string protocol { get; set; } [ServiceStack.DataAnnotations.Index(Unique = false)] public DateTime

Is it possible to do sub-query join using ServiceStack's OrmLite?

五迷三道 提交于 2019-12-11 06:33:34
问题 Is it possible to do sub-query join using ServiceStack's OrmLite? Something like this? var q = Db.From<Customer>() .Join<Customer, subq>((c, subq) => c.CustomerID == subq.CustomerID) 回答1: There's no Typed API support for joining on a sub select but you can use a CustomJoin to do this, e.g: var q = Db.From<Customer>() .CustomJoin("INNER JOIN (SELECT Id FROM ...) sub ON sub.Id = Customer.Id") 来源: https://stackoverflow.com/questions/44899741/is-it-possible-to-do-sub-query-join-using

Create (and select from) a table dynamically using servicestack ormlite

我与影子孤独终老i 提交于 2019-12-11 06:19:24
问题 I am using C# , and I try to create a table, using ServiceStack.OrmLite , corresponding to a class type created in run-time , I searched for the topic and I have found the following solution: After creating the type in runtime (employeeType) , I could do the following: db.CreateTableIfNotExists(employeeType); This would create the table Employee corresponding to the (dynamically created type "Employee") Then, by using the following: var typedApi = db.CreateTypedApi(employeeType); I could get

Servicestack: Handle indexes, auto increment etc without attributes?

旧街凉风 提交于 2019-12-11 04:55:16
问题 I am testing OrmLite, and I am looking at how to handle indexes in the tables that are created. The only way that I have found if you want to mark something as an index, unique, auto_increment etc is via attributes, like this: Index(Unique = true)] // Creates Unique Index public string Email { get; set; } However, OrmLite/ServiceStack states that: Map a POCO class 1:1 to an RDBMS table, cleanly by conventions, without any attributes required. And I was thus hoping that there are other ways of

Delete and update with stored procedure in ormlite (SQL Server) & C#

安稳与你 提交于 2019-12-11 02:46:37
问题 Trying to update using stored procedures in ormlite. I currently have this but it doesn't seem to be working. No error displayed, just does nothing. public void UpdateUsers(DATOS.Users users) { _db.SqlScalar<DATOS.Users>("exec updateUsers set @Username, @password, @id_room, @id_rol", new { Username = users.Username, Password = users.password, Id_room = users.id_room, id_rol = users.id_rol }); } Also what will do the trick for the delete? 回答1: If the stored procedure doesn't return anything

ServiceStack - [Reference] or [Ignore]?

﹥>﹥吖頭↗ 提交于 2019-12-11 02:28:50
问题 We have a DTO - Employee - with many (> 20) related DTOs and DTO collections. For "size of returned JSON" reasons, we have marked those relationships as [Ignore]. It is then up to the client to populate any related DTOs that they would like using other REST calls. We have tried a couple of things to satisfy clients' desire to have some related Employee info but not all: We created a new DTO - EmployeeLite - which has the most-requested fields defined with "RelatedTableNameRelatedFieldName"

Servicestack ORMLite/Massive managing multiple DataTables with Expandos / Dynamic?

假如想象 提交于 2019-12-11 00:07:35
问题 i have a Stored Procedure that returns multiple datatables with dynamic types according to the input and I cannot modify or split it. I actually retrieve the data in this way: var massiveModel = new DynamicModel(dbConn.ConnectionString); var connection = new SqlConnection(@"Data Source=127.0.0.1;Initial Catalog=TEST;User ID=as;Password=;Application Name=BRUCE_WAYNE"); connection.Open(); var massiveConnection = connection; var tmp = massiveModel.Query("exec MY_SP 4412 '20131016' ",

servicestack ormlite sqlite DateTime getting TimeZone adjustment on insert

懵懂的女人 提交于 2019-12-10 18:36:11
问题 i'm trying ormlite. i'm finding that when i insert an object with a DateTime property, it is getting -8:00 (my timezone is +8) applied by ormlite. It should be inserted with literally what the time is. in my case it is already UTC. however reading the values out of ormlite, the +8 is not getting re-applied. is this a known bug? thanks 回答1: I think it is inserted in UTC kind. After reading DateTime from database try to apply .ToLocalTime() 回答2: So your question looks related to this pull