ormlite-servicestack

Timeout expired. - Using Db in ServiceStack Service

谁都会走 提交于 2019-12-03 14:22:47
I'm using the Db property in a ServiceStack service to access my database but every now and then I get the following error from IIS: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. Stack Trace: [InvalidOperationException: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.] System.Data.ProviderBase.DbConnectionFactory

With OrmLite, is there a way to automatically update table schema when my POCO is modified?

…衆ロ難τιáo~ 提交于 2019-12-03 12:57:38
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. No there is no current support for Auto Migration of RDBMS Schema's vs POCOs in ServiceStack's OrmLite . There are currently a few

ServiceStack OrmLite Sql Query Logging

馋奶兔 提交于 2019-12-03 12:21:39
问题 As per the Service Stack Ormlite documentation. I should generate the sql query in debug mode. But, I am not able to see those queries. Simple code private static readonly string DataDirLoc = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\TargetIntegration\\Test\\Debug\\"; private readonly string dbFileName = DataDirLoc + "Test.db3"; [Test] public void Can_Generate_log() { //var writer = new TextWriterTraceListener(System.Console.Out); //Debug.Listeners.Add(writer);

ServiceStack OrmLite with multiple Database Servers

扶醉桌前 提交于 2019-12-03 11:43:03
问题 I'm building an app around the servicestack framework and need to be able to access data in both Oracle and MS Sql Server. Is this possible using ORMLite, it seems that I can only set a single dialect for the App or have I missed something? 回答1: Yes it is possible and support for this is already built into the OrmLiteConnectionFactory , see the Master SQLServer + Sqlite shard example on OrmLite's project home page. Basically you would register your default (or master) connection first with:

Paging in servicestack ormlite

∥☆過路亽.° 提交于 2019-12-03 06:04:39
I am looking for a good way to implement paging in ormlite and I found another question , which has this snippet: var data = db.Select<address>(predicate).Skip((int) pageNumber).Take((int) pageSize).ToList(); Problem with the above is that it gets back all the results and then does the skip and take on it which defeats the purpose of paging. At another google groups post I have found the same problem and a sample in a github issue is mentioned as a solution but the URL no longer works. Does anyone know how to correctly page using servicestack? Found the answer in ormlite's tests. Essentially

ServiceStack OrmLite Sql Query Logging

爱⌒轻易说出口 提交于 2019-12-03 03:36:28
As per the Service Stack Ormlite documentation . I should generate the sql query in debug mode. But, I am not able to see those queries. Simple code private static readonly string DataDirLoc = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\TargetIntegration\\Test\\Debug\\"; private readonly string dbFileName = DataDirLoc + "Test.db3"; [Test] public void Can_Generate_log() { //var writer = new TextWriterTraceListener(System.Console.Out); //Debug.Listeners.Add(writer); Debug.Write("this is a try"); var dbFact = new OrmLiteConnectionFactory("Data Source={0};Version=3;"

ServiceStack: Testing OrmLite, installed with NuGet but I get error “FileNotFoundException”

人盡茶涼 提交于 2019-12-01 09:34:35
I just installed OrmLite (for MySql) via NuGet in Visual Studio 2012. The installation passes without any errors, and all DLL:s seem to be added as reference: ServiceStack.Common (3.9.70.0) ServiceStack.Interfaces (1.0.0.0) ServiceStack.Text (3.9.70.0) ServiceStack.OrmLite (3.9.70.0) ServiceStack.OrmLite.MySql (3.9.70.0) Compile gives no errors. However, when I run this line: dbConnCommOrm.CreateTableIfNotExists<ModuleSettings>(); Then I get this error: Could not load file or assembly 'ServiceStack.Common, Version=3.9.69.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The

Inject TableName as Parameter for Update & Insert on GenericEntity in ServiceStack Ormlite

我与影子孤独终老i 提交于 2019-12-01 01:56:05
I have 3 tables of same structure so i have created the following entity using ServiceStack public class GenericEntity { [Alias("COL_A")] public string ColumnA { get; set; } } For retriving the results I use the following line of code. In it I pass the table name like "TableA"/"TableB" so that i can pull the appropriate results db.Select<GenericEntity>(w => w.Where(whereExperssion).OrderBy(o => o.ColumnA).From("TableA")); For delete i use the following code db.Delete<GenericEntity>(w => w.Where(q => q.ColumnA == "A").From("TableA")); With From() I can pass table name for SELECT & DELETE

Inject TableName as Parameter for Update & Insert on GenericEntity in ServiceStack Ormlite

ⅰ亾dé卋堺 提交于 2019-11-30 21:15:21
问题 I have 3 tables of same structure so i have created the following entity using ServiceStack public class GenericEntity { [Alias("COL_A")] public string ColumnA { get; set; } } For retriving the results I use the following line of code. In it I pass the table name like "TableA"/"TableB" so that i can pull the appropriate results db.Select<GenericEntity>(w => w.Where(whereExperssion).OrderBy(o => o.ColumnA).From("TableA")); For delete i use the following code db.Delete<GenericEntity>(w => w

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

China☆狼群 提交于 2019-11-30 12:18:48
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 uow = CreateUnitOfWork()) { MyFooRepository.Delete(4); MyBarRepository.Delete(7); uow.Commit(); //now