Skip to main content

Posts

Showing posts from May, 2015

How to use "PetaPoco - A tiny ORM-ish thing for your POCOs"

PetePoco is a tiny, fast, single-file micro-ORM for .NET and Mono. It is a single file that you easily add to any project. It works wit strongly typed POCO's. It supports a close relationship between object and database table. It is fast because it uses dynamic method generations (MSIL) to assign column values to properties.  Click here to read moreabout PetaPoco .. And this is how you can use it to insert, update, delete and retrieve the records, it is amazing and easy to use! Add PetePoco package to your project by using Nuget ( http://nuget.org/List/Packages/PetaPoco ) After installation you will see the PetaPoco class added to your project. It is ready to use and this is how you can use it! [PetaPoco. TableName ( "fsCarts" )] [PetaPoco. PrimaryKey ( "RecordID" )] public class Cart {   [ Key ]    public int RecordId { get ; set ; }    public string CartId { get ; set ; }    public Guid ProductId { get ; s

Converting Enum Values to Generic List

Working with Enum values is very useful in so many circumstances and when you need to covert these enum values to List<SelectListItem>, here is how you can do it; public List<SelectListItem> GetPaymentOptions() {     PaymentOptions[] values = (PaymentOptions[])Enum.GetValues(typeof(PaymentOptions));     var list = from value in values                select new SelectListItem()                {                    Value = ((int)value).ToString(),                    Text = value.ToString()                 };     List<SelectListItem> paymentOptions = list.ToList<SelectListItem>();     return paymentOptions; } That is all- nice and simple! Happy coding!