ormlite-servicestack

OrmLite With Filestream

爷,独闯天下 提交于 2019-12-13 06:04:51
问题 I did some searching and I could not find very much on utilizing filestream with OrmLite. I think it is possible but I am not sure which direction to take. Ideally I would like to be able to create or drop/create a table based on a model with a binary field and then do something to make that column in the database mapped to the filestream. I know that the filestream has to be setup on sql server ahead of time (I don't think you can do ALL the filestream setup from outside of the Management

Servicestack Ormlite Automapping

时光毁灭记忆、已成空白 提交于 2019-12-13 03:56:05
问题 I have started using ServiceStack and OrmLite for the first time and have got myself in a bit of a pickle. I have built 2 classes, 1 is to take the input parameters and 1 is to hold the response. Here they are... [DataContract] public class EMEM { public int EMCo { get; set; } public string Location { get; set; } public string Department{ get; set; } [DataMember] public string Equipment { get; set; } [DataMember] public string udDriver { get; set; } [DataMember] public string udDrillRigCrew {

ORMLite OpenTransaction batch Insert & Getting back new Guids

旧时模样 提交于 2019-12-13 02:15:57
问题 I am trying to use ServiceStack ORMLite to run this: using (var o = Conn.OpenDbConnection()) { using (var t = o.OpenTransaction()) { foreach(var item in items) o.Insert(item); t.Commit(); //now, how do I get back the new item ids I have just inserted? } } In the code, how do I get back the batch new Ids? Also noticed the non-batch version GetLastInsertId() only return a Long. What do I do when my Id type is a GUID? Thank you. Also, while you are here, I would like to also ask, if t.Commit();

Parameterizing a ServiceStack custom SQL query

て烟熏妆下的殇ゞ 提交于 2019-12-12 22:55:36
问题 I have the following custom SQL Query with OrmLite: var results = db.Select<Tuple<Customer,Purchase>>(@"SELECT c.*, 0 EOT, p1.* FROM customer c JOIN purchase p1 ON (c.id = p1.customer_id) LEFT OUTER JOIN purchase p2 ON (c.id = p2.customer_id AND (p1.date < p2.date OR p1.date = p2.date AND p1.id < p2.id)) WHERE p2.id IS NULL;"); What is the best way to add an optional WHERE clauses to, for instance, filter a given customer name field when the field has a value or to add pagination to the query

Multiple Nested Tables - ServiceStack Ormlite

拥有回忆 提交于 2019-12-12 14:24:27
问题 I have a set of nested tables eg. Customer -> Customer Order -> Order Details…. which Im using with service stack and ormlite... I need to be able to be able to pass in a customerid and then return a json feed with customer orders nested within the customer object and order details nested within each customer order object... struggling to acheive this. Ive seen a plural site vid that handles down to the second layer and works well eg. var customer = Db.GetByIDorDefault<Customer>(CustomerId);

ServiceStack.OrmLite equivalent of Single/SingleOrDefault from Entity Framework

谁说我不能喝 提交于 2019-12-12 05:28:14
问题 Currently when using OrmLite library from ServiceStack if I want single entity selected I do: AppUser user = db.First<AppUser>(q => q.Id == id); However since Single is more precise (obviously I want exception thrown if somehow multiple users with same id ended up in database) I was wondering if there is overload that I can use. Currently when I do db.Single I just get that overload with manual filtering: public static T SingleOrDefault<T>(this IDbConnection dbConn, string filter); 回答1: OK, I

VeraCode Reports ServiceStack OrmLite with Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') (CWE ID 89)

[亡魂溺海] 提交于 2019-12-12 02:06:05
问题 Ok, so I am using ServiceStack OrmLite for my data needs in my Web API. When I submitted my code to VeraCode for code security scanning and verification the result report showed that OrmLite shows potential SQL Injection attack vectors. ServiceStack.OrmLite.dll GridReader DapperMultiple(System.Data.IDbConnection, string, object, System.Data.IDbTransaction,System.Nullable<int>, System.Nullable<System.Data.CommandType>) ServiceStack.OrmLite.dll int ExecuteCommand(System.Data.IDbConnection,

ServiceStack AutoQuery - Simplify with Generic and Custom Attributes

房东的猫 提交于 2019-12-12 02:05:50
问题 This question comes from another to Simplify OrmLite with AutoQuery. ServiceStack AutoQuery allows all my different Get(AKindOfType dto) to share the same code, like below: (I have many models, like Company, my two more questions attempt to simplify the code further) // ====== Model.cs ======== [Route("/company/search")] public class QueryableCompany : QueryBase<Company> { public int? Id { get; set; } public string Company { get; set; } public int? CompanyNo { get; set; } public bool? Active

Why can I not cast IDbTransaction in ServiceStack OrmLite to DbTransaction?

烂漫一生 提交于 2019-12-11 22:22:47
问题 I am using ServiceStack.Ormlite v3.9.71 and have the following piece of code where I open an Ormlite SQLite Transaction, suppose I want to use this transaction in a command elsewhere in the code: var connFactory = new OrmLiteConnectionFactory("ConnectionString", SqliteOrmLiteDialectProvider.Instance) using (IDbConnection db = connFactory.Open()) // using var doesn't make a difference using (IDbTransaction tran = db.OpenTransaction()) // using var or even db.BeginTransaction() doesn't make a

ServiceStack.OrmLite: StringLengthAttribute.MaxText produces “LONGTEXT” - how can I set to “TEXT”?

早过忘川 提交于 2019-12-11 21:11:41
问题 Using ServiceStack's OrmLite and decorating a Property with the following attribute, creates a column of type LONGTEXT, instead o TEXT as noted in the docs: But it becomes LONGTEXT: I tried setting the StringLenghtAttribute to something else, 65535 , 70000 , Int32.MaxValue etc, but it either interpretet it as a VARCHAR and gave me the Column length too big or Row size too large , or it became a LONGTEXT. Question is: how can I force it to become "TEXT" (or any other text type in mysql)? I