Click here to Skip to main content
15,897,187 members
Articles / Mobile Apps / Windows Mobile

LINQ to SQL - Detach Entities

,
Rate me:
Please Sign up or sign in to vote.
5.00/5 (9 votes)
12 Jul 2009CPOL7 min read 101.3K   1K   36  
Easily detach entities when using LINQ to SQL
namespace Detach
{
    public partial class Order : LinqEntityBase
    {
        public override void Detach()
        {
            if (null == PropertyChanging)
                return;

            PropertyChanging = null;
            PropertyChanged = null;

            this._LineItems = Detach(this._LineItems, attach_LineItems, detach_LineItems);
            this._OrderStatus = Detach(this._OrderStatus, attach_OrderStatus, detach_OrderStatus);
        }
    }

    partial class LineItem : LinqEntityBase
    {
        public override void Detach()
        {
            if (null == PropertyChanging)
                return;

            PropertyChanging = null;
            PropertyChanged = null;

            this._Order = Detach(this._Order);
        }

    }

    partial class OrderStatus : LinqEntityBase
    {
        public override void Detach()
        {
            if (null == PropertyChanging)
                return;

            PropertyChanging = null;
            PropertyChanged = null;

            this._Order = Detach(this._Order);
        }

    }

    partial class Supplier : LinqEntityBase
    {
        public override void Detach()
        {
            if (null == PropertyChanging)
                return;

            PropertyChanging = null;
            PropertyChanged = null;

            this._Items = Detach(this._Items, this.attach_Items, this.detach_Items);
        }
    }

    partial class Item : LinqEntityBase
    {
        public override void Detach()
        {
            if (null == PropertyChanging)
                return;

            PropertyChanging = null;
            PropertyChanged = null;

            this._Product = Detach(this._Product);
            this._Supplier1 = Detach(this._Supplier1);
        }
    }

    partial class Category : LinqEntityBase
    {
        public override void Detach()
        {
            if (null == PropertyChanging)
                return;

            PropertyChanging = null;
            PropertyChanged = null;

            this._Products = Detach(this._Products, attach_Products, detach_Products);

        }
    }

    partial class Product : LinqEntityBase
    {
        public override void Detach()
        {
            if (null == PropertyChanging)
                return;

            PropertyChanging = null;
            PropertyChanged = null;

            this._Category = Detach(this._Category);
            this._Items = Detach(this._Items, attach_Items, detach_Items);
            this._Descn = Detach(this._Descn);
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect CodeSmith Tools, LLC
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Written By
Architect CodeSmith Tools
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.
This is a Organisation (No members)


Comments and Discussions