petapoco

Pass table value param to stored procedure using PetaPoco

隐身守侯 提交于 2019-12-04 20:31:37
问题 For while I am trying to call SQL Server 2008 R2 stored procedure using PetaPoco. My stored procedure accepts a table valued parameter. How I can call the stored procedure in petapoco with table value param? Here what I am trying to do: var db = new PetaPoco.Database("repikaciskaBaza"); DataTable table = new DataTable(); DataColumn id = table.Columns.Add("id", type: typeof(Int32)); for (int i = 0; i < 10;i++ ) { DataRow row = table.NewRow(); row["id"] = i; table.Rows.Add(row); } var param =

Does PetaPoco handle enums?

好久不见. 提交于 2019-12-04 17:04:01
问题 I'm experimenting with PetaPoco to convert a table into POCOs. In my table, I've got a column named TheEnum . The values in this column are strings that represent the following enum: public enum MyEnum { Fred, Wilma } PetaPoco chokes when it tries to convert the string "Fred" into a MyEnum value. It does this in the GetConverter method, in the line: Convert.ChangeType( src, dstType, null ); Here, src is "Fred" (a string ), and dstType is typeof(MyEnum) . The exception is an

Does PetaPoco handle enums?

无人久伴 提交于 2019-12-03 10:05:30
I'm experimenting with PetaPoco to convert a table into POCOs. In my table, I've got a column named TheEnum . The values in this column are strings that represent the following enum: public enum MyEnum { Fred, Wilma } PetaPoco chokes when it tries to convert the string "Fred" into a MyEnum value. It does this in the GetConverter method, in the line: Convert.ChangeType( src, dstType, null ); Here, src is "Fred" (a string ), and dstType is typeof(MyEnum) . The exception is an InvalidCastException , saying Invalid cast from 'System.String' to 'MyEnum' Am I missing something? Is there something I

Calling stored procedures with parameters in PetaPoco

旧城冷巷雨未停 提交于 2019-12-03 08:35:51
问题 I want to be able to call a stored proc with named parameters in PetaPoco. In order to call a stored proc that does a search/fetch: Can I do something like this: return db.Fetch<Customer>("EXEC SP_FindCust", new SqlParameter("@first_name", fName), new SqlParameter("@last_name", lName), new SqlParameter("@dob", dob)); Also, how can I call a stored proc that does an insert? return db.Execute("EXEC InsertCust @CustID = 1, @CustName = AAA") Thanks, Nac 回答1: Update: I tried the following for fetch

Java Micro ORM equivalent [closed]

余生颓废 提交于 2019-12-03 00:52:53
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . What would be the closest equivalent in Java to a Micro ORM such as Dapper, PetaPoco, Massive or CodingHorror? 回答1: I recommend Spring JDBC templates. While it's not a "true" ORM, it's a pleasure to use where Hibernate seems to be an overkill. 回答2: sql2o seems like a Dapper alternative - thin wrapper around JDBC

Calling stored procedures with parameters in PetaPoco

时光毁灭记忆、已成空白 提交于 2019-12-02 22:25:55
I want to be able to call a stored proc with named parameters in PetaPoco. In order to call a stored proc that does a search/fetch: Can I do something like this: return db.Fetch<Customer>("EXEC SP_FindCust", new SqlParameter("@first_name", fName), new SqlParameter("@last_name", lName), new SqlParameter("@dob", dob)); Also, how can I call a stored proc that does an insert? return db.Execute("EXEC InsertCust @CustID = 1, @CustName = AAA") Thanks, Nac Tech Xie Update: I tried the following for fetch and insert and it worked perfectly: var s = PetaPoco.Sql.Builder.Append("EXEC SP_FindCust @@last

Java Micro ORM equivalent [closed]

痴心易碎 提交于 2019-12-02 14:16:50
What would be the closest equivalent in Java to a Micro ORM such as Dapper , PetaPoco , Massive or CodingHorror ? I recommend Spring JDBC templates . While it's not a "true" ORM, it's a pleasure to use where Hibernate seems to be an overkill. sql2o seems like a Dapper alternative - thin wrapper around JDBC String sql = "SELECT id, category, duedate " + "FROM tasks " + "WHERE category = :category"; Sql2o sql2o = new Sql2o(DB_URL, USER, PASS); List<Task> tasks = sql2o.createQuery(sql) .addParameter("category", "foo") .executeAndFetch(Task.class); github - https://github.com/aaberg/sql2o site -

PetaPoco Transaction in Multithread Env

南楼画角 提交于 2019-12-01 05:15:35
I just test PetaPoco Transaction in a multithread way... I have a simple test case : -- Simple value object call it MediaDevice -- Insert a record an update it for 1000 times void TransactionThread(Object object) { Database db = (Database) object; for(int i= 0; i < 1000;i++) { Transaction transaction = db.GetTransaction(); MediaDevice device = new MediaDevice(); device.Name = "Name"; device.Brand = "Brand"; db.Insert(device); device.Name = "Name_Updated"; device.Brand = "Brand_Updated"; db.Update(device); transaction.Complete(); } long count = db.ExecuteScalar<long>("SELECT Count(*) FROM

PetaPoco Transaction in Multithread Env

∥☆過路亽.° 提交于 2019-12-01 02:25:50
问题 I just test PetaPoco Transaction in a multithread way... I have a simple test case : -- Simple value object call it MediaDevice -- Insert a record an update it for 1000 times void TransactionThread(Object object) { Database db = (Database) object; for(int i= 0; i < 1000;i++) { Transaction transaction = db.GetTransaction(); MediaDevice device = new MediaDevice(); device.Name = "Name"; device.Brand = "Brand"; db.Insert(device); device.Name = "Name_Updated"; device.Brand = "Brand_Updated"; db

How do I use the SQL WHERE IN construct with PetaPoco?

非 Y 不嫁゛ 提交于 2019-11-30 11:48:27
问题 I have a database table named Tags (Id, Name) from which I would like to select the ones where the name matches a name in a list. In SQL I would use something like: Select * from Tags Where Name In ('Name1', 'Name2', 'xxx...) But now using PetaPoco in an ASP.Net MVC3 project I'm stuck figuring out how to do it properly. So far I've tried: var tagsToFind = new string[] { "SqlServer", "IIS" }; var sql = PetaPoco.Sql.Builder.Select("*").From("Tags").Where("Name in (@0)", tagsToFind); var result