Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
ServiceStack ORMLite SqlServer example
using ServiceStack.DataAnnotations;
using ServiceStack.OrmLite;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
class Program
public static string SqlServerBuildDb = "Server=Dev2011;Database=ItemInfoDb;User Id=NewDbUser;Password=S3cretPw;";
static void Main(string[] args)
ItemInfo itemPublishInfo = new ItemInfo();
itemPublishInfo.Title = "subject.Title";
itemPublishInfo.URI = "subject.Id";
private static void SavePublishItemInDb(ItemInfo itemPublishInfo)
//Using SqlServer DB
var dbFactory = new OrmLiteConnectionFactory(
SqlServerBuildDb, SqlServerDialect.Provider);
using (var db = dbFactory.Open())
// Insert
// Read
var allItems = db.Select<ItemInfo>();
public class ItemInfo
public int Id { get; set; }
public string Title { get; set; }
public string URI { get; set; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.