FAQ Database Discussion Community


How does ServiceStack ORMLite handle Many to many relationships?

orm,many-to-many,servicestack,ormlite-servicestack
I am working on an ORMLite demo and so far, it has been doing everything I wanted it to do. However, the production DB against which we are going to work has a lot of many to many relationships where we have a landing table with composite primary key. I...

ServiceStack ormlite json does not deserialize from database

c#,serialization,servicestack,ormlite-servicestack,servicestack-text
ServiceStack ORMLite does not deserialize my class from Postgresql. Keeping the objects on cache solves, but it can't load them back (saving is ok). Below is a code that reproduces the problem. void Main() { var inv = new Inventory(); inv.Items.Add(new Item{Id=1,CreatedAt=DateTime.Now, Key="potion10", Descriptions=new Dictionary<int, string>{{1,"Poção que recupera um pouco...

ServiceStack taking a long time to execute stored procedure

c#,sql,servicestack,ormlite-servicestack,sql-server-2014
I have implemented ServiceStack (v4.0.36) with an ORMLite connection to my SQL Server 2014 database. There is a search form on my website that passes any populated fields to a "/search" route as querystring parameters. My request DTO looks like: [Route("/search", "GET")] public class SearchRequest { public string FirstName {...

Access ServiceStack session from ConnectionFilter

servicestack,ormlite-servicestack
I am using SQL Server and database triggers to keep a data-level audit of all changes to the system. This audit includes the userID / name of whomever initiated a change. Ideally I'd like to do something like this in my AppHost.Configure method: SqlServerDialect.Provider.UseUnicode = true; var dbFactory = new...

Ormlite int based enums coming as varchar(max)

servicestack,ormlite-servicestack
Can anyone tell me how to correctly get ORMLite to store enums as integers? I know that this was not supported in 2012 but i found code for some unit tests that suggest it should work now but it doesn't. When we try the column gets created as a varchar(max)...

Joining the same table multiple times in ServiceStack AutoQuery

c#,servicestack,ormlite-servicestack
I'm trying to use ServiceStack's Auto Query feature against a table A which references another table B multiple times, but can't get it to work. The root of this seems to be that AutoQuery generates joins without aliasing the joined tables, resulting in ambiguous columns. It fails both against SQL...

Whats the difference between ServiceStack.OrmLite packages and .Signed version?

c#,servicestack,ormlite-servicestack
When download the packages in Visual Studio there are two version of the same packages for ServiceStack. ServiceStack ServiceStack Signed What is the difference?...

How to globally change the command timeout using ServiceStack.OrmLite

servicestack,ormlite-servicestack
I have a reporting-based website using ServiceStack and OrmLite, using a SQL Server back-end. Due to the duration of some of the reports, I'd like to either globally, or selectively (via Service-derived class or some attribute) make queries that run reports have a longer CommandTimeout. I'd like to keep using...

OrmLite: SQLiteExceptionSQL logic error or missing database near “)”: syntax error

c#,sqlite,servicestack,ormlite-servicestack
Hi i'm trying to test out if I delete a parent object, the child will automatically be deleted too using OrmLite and the in-memory database Sqlite this is my test code but it throws me System.Data.SQLite.SQLiteExceptionSQL logic error or missing database near ")": syntax error at the db.Save() line. What...

Load all hierarchical references with Servicestack ORMLite

ormlite-servicestack
Is there any way to preload all nested and sub-nested references with servicestack / ormlite? public class Person { public int Id { get; set; } [References(typeof(Pants))] public int PantsId { get; set; } [Reference] public Pants Pants { get; set; } } public class Pants { public int Id...

ServiceStack.OrmLite SqlServer new Merge method doesn't work for different names of references

c#,sql-server,servicestack,ormlite-servicestack
I tried to use the new merge method in ServiceStack.OrmLite Sql Server it works perfectly to load references when the name of the column is the same as the Child Table: var result = dbCon.SqlList<TimeSheet>("EXEC getAllTimeSheets @timeSheetTypeId, @teamId, @employeeId, @fromDate, @toDate", new { timeSheetTypeId, teamId, employeeId, fromDate, toDate }); //...

Servicestack Ormlite seems to be ignoring my Database Schemas c#

c#,sql,servicestack,ormlite-servicestack
Hi folks quick help required if possible i'm trying to do (what i thought would be simple) a quick query. The object i'm using [Schema("Prospect")] [Alias("TrackedSource")] public class ProspectSource { [PrimaryKey] [AutoIncrement] public int Id { get; set; } public int? ClientId { get; set; } public string Name {...

How to do a GroupBy statement with ServiceStack OrmLite

ormlite-servicestack
I am doing some queries for Data Visualization and rely on GroupBy, Avg, Sum, and similar functions to get a good dataset from the DB. I would like to use something similar to GroupBy with ServiceStack OrmLite. On the ShippersExample page I see the following query. Is there an easier...

How to retrieve Data Annotation Alias(“tablename”) and Alias(“field name”) from ServiceStack ORMLite?

c#,servicestack,data-annotations,ormlite-servicestack
I need to return the alias from the Data Annotation of this class "tblAccounts" and "AccountNumber". It uses ServiceStack ORM Lite. [Alias("tblAccounts")] [Schema("task")] public class Account : IHasId<int> { [Alias("AccountNumber")] public int Id { get; set; } [Required] public int UnitId { get; set; } [Required] public int OldAccountNumber {...

MySQL decimal column precision with Servicestack ORMLite

mysql,servicestack,ormlite-servicestack
I've got a decimal attribute and I'm trying to set the precision and scale to be 12 and 2 respectively. My understanding is that I should just be able to do this by adding the DecimalLength attribute to the property like so: [DecimalLength(12,2)] public decimal? Amount { get; set; }...

Potential illegal fragment detected when using OrmLite SqlExpression with Mysql?

mysql,servicestack,ormlite-servicestack
When I try to execute the following line: var vehicles = db.Select<VehicleResponse>(q => q.Select( "SELECT make, model, year, color FROM Vehicles").Limit(skip: 0, rows: 10)); I get the error: Potential illegal fragment detected: SELECT make, model, year, color FROM Vehicles If I execute the following, I don't get the error: var...

Owin with custom ORM framework (not Entity Framework)

c#,asp.net,entity-framework,ormlite-servicestack
I was recently using Entity framework together with Identity and OWIN but no I no longer want to use Entity and instead use OrmLite from ServiceStack. The problem I'm facing right now is I don't quite understand how to replace this part from Owin startup class: `app.CreatePerOwinContext(AppDbContext.Create); app.CreatePerOwinContext<AppUserManager>(AppUserManager.Create); to use...

LINQ query fails with nullable variable ormlite

linq,servicestack,ormlite-servicestack
I'm trying to write following LINQ query using ServiceStack Ormlite. dbConn.Select<Product>(p => p.IsActive.HasValue && p.IsActive.Value) Here, Product is my item class and "IsActive" is Nullable Bool property in that class. When this line executes it always throws "InvalidOperationException" with the message variable 'p' of type '' referenced from scope '',...

Anonymous object blob in database not serializing as JSON when queried

json,servicestack,ormlite-servicestack
I have a need to store an unknown data structure in a SQL Server database table field via ORMLite. This is to support a timeline feature on a website where each step on the timeline contains different information, and I want to store them as generic "Steps", with the variable...

Post-registration action in ServiceStack

.net,authentication,servicestack,ormlite-servicestack
I have used ServiceStack for a few projects and really love it. That said, this is my first foray into dealing with user auth in any way, so forgive me if I'm making any fundamental errors in my understanding or implementation here. I need to be able to track custom...

Annotated Ignore field get's ignored in servicestack reponse

c#,servicestack,ormlite-servicestack
I have a request like this: ARequest : QueryBase<Person, Result>, IJoin<Person, OtherThing> Person has the following field [Ignore] Public string Label { get { return FirstName + LastName; } In my Result i have the following public int Id; public string Label However, if i add an Ignore attribute to...

How to use InsertOnly method in OrmLite?

servicestack,ormlite,ormlite-servicestack
Following this example, how is the correspondent for the method InsertOnly? var updated = await dbCon.UpdateOnlyAsync(timesheet, onlyFields: x => new { x.LogInTime, x.LogOffTime, x.IsFlaggedByLeader, x.LeaderComment, x.IsModified }, @where: x => x.Id == timesheet.Id) > 0; I couldn't find an example on Internet and in the Ormlite documentation. ...

ServiceStack ORMLite - Can't Infer Relationship (because of DTO name?)

servicestack,ormlite-servicestack
I am modeling a service business that performs multiple services at each visit to a client. I have a Visit table, a Service table and a link table, VisitService. I am using this Request DTO in my service to get a list of services for a visit: [Route("/visits/{visitid}/services", Verbs =...

ServiceStack OrmLite and transactions

sql-server,transactions,ormlite-servicestack
I am trying to execute sql inside a transaction using ServiceStack OrmLite. The code below works with Sqlite but not with SqlServer. With SqlServer I get the following error: ExecuteScalar requires the command to have a transaction when the connection assigned to the command is in a pending local transaction....

Convert SQL to ServiceStack.ORMLite Sql Server

c#,sql-server,tsql,servicestack,ormlite-servicestack
How to convert the following SQL to ServiceStack.OrmLite Sql Server format? /* Total Receipts */ select convert(date, t.TransactionDate) [Date], tm.TeamId,a.AccountNumber, count(distinct(t.RequisitionNumber)) Total from task.tblTransactions t inner join task.tblRequisitions r on r.RequisitionNumber = t.RequisitionNumber inner join task.tblAccounts a on a.AccountNumber = r.AccountNumber inner join Team tm on tm.DivisionId = a.DivisionId where...