ormlite-servicestack

ServiceStack OrmLite Command Timeout

霸气de小男生 提交于 2020-01-03 09:46:26
问题 When using IDbConnection.ExecuteSql how do I set the Command Timeout? IDbConnection db = ConnectionFactory.OpenDbConnection(); db.ExecuteSql("..."); If I use the IDbCommand.ExecuteSql ( See below ) method I can set the Command Timeout, but I get a bunch of warnings about deprecated methods. IDbCommand comm = db.CreateCommand() comm.CommandTimeout = 240; comm.ExecuteSql("..."); 回答1: With the most recent change OrmLite no longer provides APIs around the IDbCommand object directly (which have

Incorrect syntax near ';' - Works in SQL Server, not from Servicestack.ORMLite

混江龙づ霸主 提交于 2020-01-03 02:49:09
问题 I am executing a SQL statement through Servicestack.ORMLite. The statement is of the following format: with rowdata as ( select t1.v1, t1.v2 datakey, t2.v1 datavalue from t1 left join t2 on t2.rowid = t1.rowid ) select * from rowdata PIVOT ( SUM(datavalue) FOR datakey IN ([1],[2],[3],[4],[5]) )AS PivtTable This executes correctly in SQL Server, and in Oracle (with a few small changes). However, when executing through Servicestack.ORMLite using the 'db.Select (sql)' command, I get the

ServiceStack / ORM Lite - Foreign Key Relationships

有些话、适合烂在心里 提交于 2020-01-01 16:22:38
问题 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 / 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 {

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

Using schema names with SQL Server & ServiceStack.OrmLite

亡梦爱人 提交于 2020-01-01 08:20:35
问题 Anyone know how to apply the correct Alias attribute to query tables with schema names? I have a table called accounts.register . I've tried using [Alias("accounts.register")] as the class decorator attribute for Register class but this doesn't work. If I change the schema to dbo then I can remove the alias and everything works. Unfortunately I have a legacy system with many schemas so I need this to work. 回答1: OK I figured it out. Along with the Alias attribute is the Schema attribute. The

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

Many to many relations with ServiceStack.OrmLite

孤者浪人 提交于 2019-12-29 04:58:05
问题 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!! 回答1: 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

How to change sql server connection string dynamically in service stack

↘锁芯ラ 提交于 2019-12-25 06:37:48
问题 I am working on Asp.Net MVC and ServiceStack. I am trying to connect to the sql server database using servicestack ormlite. like var connectionString = ConfigurationManager.ConnectionStrings["AppDb"].ConnectionString; container.Register<IDbConnectionFactory>( new OrmLiteConnectionFactory(connectionString, SqlServerOrmLiteDialectProvider.Instance) { ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current) }); I am able to connect to database, But in my scenario i need to change