ormlite-servicestack

Create a column with varchar(max) rather than varchar(8000)

泪湿孤枕 提交于 2019-12-05 01:38:54
How can I create a column in a table and specify it as varchar(max) when using servicestack ormlite? Currently I execute some sql after the table create to get what I want. I've seen the StringLength attribute but was wondering if there's a nicer way of doing it? Something like StringLength(Sql.VarcharMax) Thanks Worked around the issue by doing the following if (!db.TableExists(typeof(Entity).Name)) { db.CreateTableIfNotExists<Entity>(); db.ExecuteSql("ALTER TABLE Entity ALTER COLUMN Column VARCHAR(MAX)"); } Decorate your domain model with System.ComponentModel.DataAnnotations

SQL Server specific types support for OrmLite

断了今生、忘了曾经 提交于 2019-12-04 23:13:30
I just learned about a genius type that would simplify a lot of my work but it looks like my preferred ORM does not recognize it. Is there a workaround to let ServiceStack OrmLite recognize HierarchyId in SQL Server? Any suggestions about which files to modify and any hints how to proceed? EDIT : Here is a better illustration of the problem. I have the following class: public class MyClass { public int Id { get; set; } public SqlHierarchyId HierarchyId { get; set; } } SqlHierarchyId is a custom SQL Server data type. OrmLite will generate the following class for it: Funny enough, I can use the

How to perform a more complex query with AutoQuery

守給你的承諾、 提交于 2019-12-04 22:13:23
Given the following definitions from a ServiceStack endpoint: public class LoanQueue { public int LoanId { get; set; } public DateTime Submitted { get; set; } public DateTime Funded { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public int Fico { get; set; } public int Fraud { get; set; } public int CDS { get; set; } public int IDA { get; set; } public string Income { get; set; } public string Liabilities { get; set; } public string Agent { get; set; } public string Status { get; set; } public string State { get; set; } public string Product { get; set

ServiceStack / ORM Lite - Foreign Key Relationships

北慕城南 提交于 2019-12-04 15:23:10
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 { get; set; } } It has a FK on my Comment and Tag entities. So I'd like to return those in my response

Does ORMLite support dynamic Type of C#?

不打扰是莪最后的温柔 提交于 2019-12-04 15:07:51
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? By design OrmLite does not support marshalling to dynamic types, and expects resultsets to mapped to Typed POCO's. Although it does have specialized API's to access Dynamic Result

How do I increase the Command Timeout in OrmLite ServiceStack?

∥☆過路亽.° 提交于 2019-12-04 11:27:32
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; } When putting a break point on the Db object, I can see the connection time out to be 666 but I can't

How to define 'geography' type using Npgsql and OrmLite (using postgresql, postgis, c#)

隐身守侯 提交于 2019-12-04 04:02:55
How do I define a postgis 'geography' type in my C# class model so that OrmLite can easily pass it through to Postgresql so I can run spatial queries in addition to saving spatial data to the 'geography' column? The best library is NetTopologySuite for this case; you can use like this; protected GisSharpBlog.NetTopologySuite.Geometries.Geometry _geom; public GisSharpBlog.NetTopologySuite.Geometries.Geometry Geom { get { return _geom; } set { _geom = value; } } protected string _geomwkt; public virtual string GeomWKT { get { if (this.Geom != null) return this.Geom.ToText(); else return ""; }

How to use Dapper in ServiceStack

◇◆丶佛笑我妖孽 提交于 2019-12-04 03:07:28
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.Provider)); container.Register<IDbConnection>(c => c.Resolve<IDbConnectionFactory>().OpenDbConnection())

Transactions in the Repository Pattern using ServiceStack.ORMLite

不打扰是莪最后的温柔 提交于 2019-12-04 02:50:00
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 need to warp some DB operation in a DbTransaction.It looks like TransactionScope is a solution but I

Using schema names with SQL Server & ServiceStack.OrmLite

本小妞迷上赌 提交于 2019-12-04 00:35:28
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. OK I figured it out. Along with the Alias attribute is the Schema attribute. The former is in the ServiceStack.DataAnnotations namespace but the latter is in the ServiceStack.OrmLite