Advertisement
ampedPF

Untitled

Jul 15th, 2015
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.95 KB | None | 0 0
  1. class User
  2. {
  3.     [AutoIncrement] // Creates Auto primary key
  4.     public int Id { get; set; }
  5.  
  6.     public string Username { get; set; }
  7.     public string Email { get; set; }
  8.     public string Password { get; set; }
  9.     public bool IsPremium{ get; set; }
  10.     public DateTime? LastUpdated { get; set; }
  11. }
  12.  
  13.  
  14. class Relationship
  15. {
  16.     public int User_one_id { get; set; }    // FK User.Id
  17.     public int User_two_id { get; set; }    // FK User.Id
  18.     public int Status { get; set; }
  19.     public int Action_user_id{ get; set; }
  20. }
  21.  
  22.  
  23. class Claim
  24. {
  25.     [AutoIncrement] // Creates Auto primary key
  26.     public int Id { get; set; }
  27.  
  28.     public int User_one_id { get; set; }    // FK User.Id
  29.     public int User_two_id { get; set; }    // FK User.Id
  30.     public int Object_id { get; set; }  // FK Object.Id
  31.     public int Object_count { get; set; }
  32.     public DateTime? LastUpdated { get; set; };
  33. }
  34.  
  35.  
  36. class Object
  37. {
  38.     [AutoIncrement] // Creates Auto primary key
  39.     public int Id { get; set; }
  40.  
  41.     public string LongName { get; set; }
  42.     public string ShortName { get; set; }
  43.     public string Description { get; set; }
  44. }
  45.  
  46.  
  47.  
  48. ================================================================================================
  49. using System;
  50. using System.Collections.Generic;
  51. using System.Linq;
  52. using System.Text;
  53. using ServiceStack.DataAnnotations;
  54. using ServiceStack.OrmLite;
  55. using ServiceStack.OrmLite.Sqlite;
  56. using System.Data;
  57. using ServiceStack.Common.Utils;
  58.  
  59. public void addUserToDb() {
  60.     public static string SqliteMemoryDb = ":memory:";
  61.     public static string SqliteFileDb = "~/App_Data/db.sqlite".MapAbsolutePath();
  62.  
  63.     //Using Sqlite DB
  64.     var dbFactory = new OrmLiteConnectionFactory(
  65.         SqliteFileDb, false, SqliteDialect.Provider);
  66.  
  67.     using (var db = dbFactory.Open()) {
  68.  
  69.         db.CreateTableIfNotExists<User>();
  70.  
  71.         // Insert
  72.         db.Insert(
  73.             new User {
  74.                 Username = Username ,
  75.                 Email = "ampedpf@ct.com",
  76.                 Password = "password1",
  77.                 IsPremium = true,
  78.                 LastUpdated = new DateTime(2015, 1, 5) });
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement