petapoco

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

扶醉桌前 提交于 2019-11-30 01:26:51
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 = db.Query<Tag>(sql); Which results in the following SQL, where only the first name in my list of

In PetaPoco, how to decorate a table that has multi-columns primary keys

非 Y 不嫁゛ 提交于 2019-11-29 19:27:53
问题 In the example given on PetaPoco's web site, this is how to decorate a class: [PetaPoco.TableName("articles")] [PetaPoco.PrimaryKey("article_id")] public class article { public long article_id { get; set; } public string title { get; set; } public DateTime date_created { get; set; } public bool draft { get; set; } public string content { get; set; } } But assume that the table articles was modeled to have 2 columns: article_id and title as its primary key (instead of just article_id), then

how to create a DAL using petapoco [closed]

六眼飞鱼酱① 提交于 2019-11-28 07:37:57
I need to create a DAL and repositories using petapoco. The difficulty that comes in, is that I dont know how it manages its connections. If I was using dapper I know how the connection process flows because I control it. I don't know what are the best practices in creating a DAL with petapoco. public class UserRepository { public IEnumerable<User> All() { var db = new PetaPoco.Database("Sqlite_Connection");//this line var s = db.Query<User>("SELECT * FROM Users"); return s.ToList(); } } I would like to place var db = new PetaPoco.Database("Sqlite_Connection");//this line in my DALHelper class

how to create a DAL using petapoco [closed]

微笑、不失礼 提交于 2019-11-27 01:59:04
问题 I need to create a DAL and repositories using petapoco. The difficulty that comes in, is that I dont know how it manages its connections. If I was using dapper I know how the connection process flows because I control it. I don't know what are the best practices in creating a DAL with petapoco. public class UserRepository { public IEnumerable<User> All() { var db = new PetaPoco.Database("Sqlite_Connection");//this line var s = db.Query<User>("SELECT * FROM Users"); return s.ToList(); } } I