ormlite-servicestack

ServiceStack.OrmLite: Where is the method to write custom SQL and get result set back?

旧街凉风 提交于 2019-12-06 09:26:17
I have been reading on https://github.com/ServiceStack/ServiceStack.OrmLite to find methods so I can execute normal SQL (string commands), and get a result set back, but I dont think there is any. I am testing OrmLite v 4.0.17.0. On the page above, there is a method SqlList mentioned, but I have no such method available: I have an ExecuteSql, but I get no result set back, just an int: So, two questions: Is there a way to execute custom queries, a method that takes in a string as parameter, and where I then get back a result set, rows or objects or something? And while I am at it, how do I

Does ORMLite support dynamic Type of C#?

主宰稳场 提交于 2019-12-06 09:17:48
问题 I am looking into ORMLite from ServiceStack and what I am trying to do here is that call a stored procedure which in turn return many many rows which definitely would not be bound to any domain object but also may or may not have a dto object to map with. I was wondering if I can bind it to a type. However, it sounds like ORMLite does not support dynamic type binding at this time. Does ORMLite support at this point? 回答1: By design OrmLite does not support marshalling to dynamic types, and

Populating POCO's with ServiceStack.OrmLite

别来无恙 提交于 2019-12-06 05:01:01
Consider the following domain model: class Customer { int id {get;set} string Name {get;set} List<Contact> Contacts {get;set} } class Contact { int id {get;set} string FullName {get;set} List<PhoneNumber> {get;set} } class PhoneNumber { int id {get;set} PhoneType Type {get;set} string Number {get;set} } Customer, Contact & PhoneNumbers are separate entities in our DB. Any Suggestions as to how to populate a full customer with all its linked contacts and the contacts phone numbers in the most efficient way using ORMLite and/or Dapper, with consideration of calls to the db and cpu cycles to map

How do I increase the Command Timeout in OrmLite ServiceStack?

一个人想着一个人 提交于 2019-12-06 04:53:09
问题 I am using ServiceStack OrmLite SqlServer v3.9.71 and have the following connection string: <add key="ConnStr" value="Data Source=my-db;Initial Catalog=Users;Integrated Security=SSPI;Connection Timeout=666"/> and am using the following to run a query which takes 2-3 minutes to come back: using (Db) { var result = new ResultDto(); Parallel.Invoke( () => { result.StatOne = Db.Dictionary<DateTime, int>(query1); }, () => { result.StatTwo = Db.Dictionary<DateTime, int>(query2); } ); return result;

How to pass non-optional NULL parameters to a Stored Proc using OrmLite

牧云@^-^@ 提交于 2019-12-06 00:41:41
I'm using OrmLite against an existing SQL Server database that has published stored procedures for access. One of these SPs takes 3 int parameters, but expects that one or another will be null. However, none of the parameters are declared optional. Here's the code I've tried: using (IDbConnection scon = myFactory.OpenDbConnection()) { rowCount = scon.SqlScalar<int>("EXEC myProc @FileID, @FileTypeID, @POID", new { FileID = req.FileId, FileTypeID = (int?)null, POID = req.PoId, }); } But this produces a SqlException: Must declare the scalar variable "@FileTypeID". Examining the

Is it possible to create a cross-database query with ServiceStack ORMLite?

被刻印的时光 ゝ 提交于 2019-12-05 21:52:34
Pretty much summed up in the title. Trying to hit a table in one database and join it to a table in another database on the same server. I would have assumed an attribute for Database that I could decorate the POCO with, but do not see one that would be appropriate. Currently using this syntax: var result = db.Select<Model.Dto>( db.From<Data.Dto1>() .Join<Data.Dto2>(d1, d2) => d1.Id == d2.Id)); There's no specific attribute for specifying an external database but in RDBMS's that support cross-database queries you should be able to use the [Schema] attribute, e.g: [Schema("Server1.Database1.dbo

UpdateNonDefaults is ignoring boolean parameters set to false

萝らか妹 提交于 2019-12-05 18:46:29
I'm trying to update a record in my SQL server 2012 Express DB using UpdateNonDefaults. Boolean fields which are set to false are getting ignored as can be seen from the SQL statement. How can I set DB value to false for boolean fields using UpdateNonDefaults? Thanks in advance.. Please post your code, or we can't tell what is wrong... Try: [Default(typeof(bool?), null)] public bool? Foo {get;set;} Or try : [Default(typeof(int?), null)] public int? Foo {get; set;} See if it works? As a work-around, I have changed my "bool" data types to "string" and am using bool.FalseString and bool

ServiceStack OrmLite How can I achieve automatic setting of foreign key/related properties?

房东的猫 提交于 2019-12-05 17:19:10
I have created the following example to test Foreign Keys and up to this point, it works well. What I would like to be able to do, is use this framework that I built to set the property of the relationship and have it Save the child object when the Parent is saved and automatically set the PrimaryKey and Foreign Key. The DataManager class exposes the Connection public class DataManager { DataManager() { OrmLiteConfig.DialectProvider = SqliteDialect.Provider; ConnectionString = SqliteFileDb; updateTables(); } private void updateTables() { using (var dbConn = OpenDbConnection()) { dbConn

How to use Dapper in ServiceStack

妖精的绣舞 提交于 2019-12-05 16:42:59
问题 Currently, I am using OrmLite for DB operations. I am also planning to use Dapper ORM, but can anyone point me how to integrate DapperORM in ServiceStack. Do I need to implement both IDbConnection and IDbConnectionFactory interfaces with Dapper and plugin into the container. public override void Configure(Container container) { container.Register<IDbConnectionFactory>( c => new OrmLiteConnectionFactory(ConfigurationManager.ConnectionStrings["default"].ConnectionString, SqlServerDialect

OrmLite query to select some of the columns from each of 2 joined tables

主宰稳场 提交于 2019-12-05 10:06:47
Following on from this comment , how can I do a ServiceStack OrmLite query that joins two or more tables and returns some of the columns from each of them? Using the OrmLite Does_only_populate_Select_fields_wildcard unit test as example, I'd like to do something like this: public class DeptEmployee { [PrimaryKey] public int Id { get; set; } public string FirstName { get; set; } public string LastName { get; set; } [References(typeof(Department2))] public int DepartmentId { get; set; } [Reference] public Department2 Department { get; set; } } public class Department2 { [PrimaryKey] public int