Demo of ADO.NET POCO with SQLite database

This demonstration shows how to prepare for and how to implement model-first ADO.NET POCO objects with a SQLite backing store.

C# (46.5 KB)
 
 
 
 
 
5 Star
(1)
3,378 times
Add to favorites
9/12/2011
E-mail Twitter del.icio.us Digg Facebook
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated from a template.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;

namespace POCOWithSQLiteDemo.Model
{
    public partial class Post
    {
        #region Primitive Properties
    
        public virtual long Id
        {
            get;
            set;
        }
    
        public virtual string Author
        {
            get;
            set;
        }
    
        public virtual System.DateTime Date
        {
            get;
            set;
        }
    
        public virtual string Content
        {
            get;
            set;
        }

        #endregion
        #region Navigation Properties
    
        public virtual Blog Blogs
        {
            get { return _blogs; }
            set
            {
                if (!ReferenceEquals(_blogs, value))
                {
                    var previousValue = _blogs;
                    _blogs = value;
                    FixupBlogs(previousValue);
                }
            }
        }
        private Blog _blogs;

        #endregion
        #region Association Fixup
    
        private void FixupBlogs(Blog previousValue)
        {
            if (previousValue != null && previousValue.Posts.Contains(this))
            {
                previousValue.Posts.Remove(this);
            }
    
            if (Blogs != null)
            {
                if (!Blogs.Posts.Contains(this))
                {
                    Blogs.Posts.Add(this);
                }
            }
        }

        #endregion
    }
}