I have made a little example:
Two tables, cities and people. Peoples are born in a city and live
there too. I have attached the SQL Create script and the generated C#
file. In this example I got 4 error messages:
Error   1       The type 'citypeopleLinq.Cities' already contains a definition
for '_people'   T:\DotNet\citypeople\citypeople\citypeople.cs   123     29
citypeople
Error   2       Type 'citypeopleLinq.Cities' already defines a member called
'People_Attach' with the same parameter types   T:\DotNet\citypeople
\citypeople\citypeople.cs       153     16      citypeople
Error   3       Type 'citypeopleLinq.Cities' already defines a member called
'People_Detach' with the same parameter types   T:\DotNet\citypeople
\citypeople\citypeople.cs       158     16      citypeople
Error   4       The type 'citypeopleLinq.People' already contains a definition
for '_cities'   T:\DotNet\citypeople\citypeople\citypeople.cs   322     29
citypeople



################ This is the SQL Script to create the database
#########################################
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS,
FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';

CREATE SCHEMA IF NOT EXISTS `citypeople` DEFAULT CHARACTER SET latin1
COLLATE latin1_swedish_ci ;
USE `citypeople`;

-- -----------------------------------------------------
-- Table `citypeople`.`Cities`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `citypeople`.`Cities` ;

CREATE  TABLE IF NOT EXISTS `citypeople`.`Cities` (
  `ID` INT NOT NULL ,
  `CityName` VARCHAR(45) NULL ,
  PRIMARY KEY (`ID`) )
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `citypeople`.`People`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `citypeople`.`People` ;

CREATE  TABLE IF NOT EXISTS `citypeople`.`People` (
  `ID` INT NOT NULL AUTO_INCREMENT ,
  `LastName` VARCHAR(45) NULL ,
  `BornIn_ID` INT NOT NULL ,
  `LivesIn_ID` INT NOT NULL ,
  PRIMARY KEY (`ID`, `BornIn_ID`, `LivesIn_ID`) ,
  INDEX `fk_People_Cities` (`BornIn_ID` ASC) ,
  INDEX `fk_People_Cities1` (`LivesIn_ID` ASC) ,
  CONSTRAINT `fk_People_Cities`
    FOREIGN KEY (`BornIn_ID` )
    REFERENCES `citypeople`.`Cities` (`ID` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_People_Cities1`
    FOREIGN KEY (`LivesIn_ID` )
    REFERENCES `citypeople`.`Cities` (`ID` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;



SET sql_mo...@old_sql_mode;
SET foreign_key_chec...@old_foreign_key_checks;
SET unique_chec...@old_unique_checks;
#########################################################

################### This is the generated source file
######################################
#region Auto-generated classes for citypeople database on 2009-03-31
14:31:37Z

//
//  ____  _     __  __      _        _
// |  _ \| |__ |  \/  | ___| |_ __ _| |
// | | | | '_ \| |\/| |/ _ \ __/ _` | |
// | |_| | |_) | |  | |  __/ || (_| | |
// |____/|_.__/|_|  |_|\___|\__\__,_|_|
//
// Auto-generated from citypeople on 2009-03-31 14:31:37Z
// Please visit http://linq.to/db for more information

#endregion

using System;
using System.Data;
using System.Data.Linq.Mapping;
using System.Diagnostics;
using System.Reflection;
using DbLinq.Data.Linq;
using DbLinq.Vendor;
using System.ComponentModel;

namespace citypeopleLinq
{
        public partial class CityPeople : DataContext
        {
                public CityPeople(IDbConnection connection)
                : base(connection, new DbLinq.MySql.MySqlVendor())
                {
                }

                public CityPeople(IDbConnection connection, IVendor vendor)
                : base(connection, vendor)
                {
                }

                public Table<Cities> Cities { get { return GetTable<Cities>(); 
} }
                public Table<People> People { get { return GetTable<People>(); 
} }

        }

        [Table(Name = "citypeople.cities")]
        public partial class Cities : INotifyPropertyChanged
        {
                #region INotifyPropertyChanged handling

                public event PropertyChangedEventHandler PropertyChanged;

                protected virtual void OnPropertyChanged(string propertyName)
                {
                        if (PropertyChanged != null)
                        {
                                PropertyChanged(this, new 
PropertyChangedEventArgs(propertyName));
                        }
                }

                #endregion

                #region string CityName

                private string _cityName;
                [DebuggerNonUserCode]
                [Column(Storage = "_cityName", Name = "CityName", DbType = 
"varchar
(45)")]
                public string CityName
                {
                        get
                        {
                                return _cityName;
                        }
                        set
                        {
                                if (value != _cityName)
                                {
                                        _cityName = value;
                                        OnPropertyChanged("CityName");
                                }
                        }
                }

                #endregion

                #region int ID

                private int _id;
                [DebuggerNonUserCode]
                [Column(Storage = "_id", Name = "ID", DbType = "int", 
IsPrimaryKey =
true, CanBeNull = false)]
                public int ID
                {
                        get
                        {
                                return _id;
                        }
                        set
                        {
                                if (value != _id)
                                {
                                        _id = value;
                                        OnPropertyChanged("ID");
                                }
                        }
                }

                #endregion

                #region Children

                private EntitySet<People> _people;
                [Association(Storage = "_people", OtherKey = "BornInID", Name =
"fk_People_Cities")]
                [DebuggerNonUserCode]
                public EntitySet<People> People_BornInID
                {
                        get
                        {
                                return _people;
                        }
                        set
                        {
                                _people = value;
                        }
                }

                private EntitySet<People> _people;
                [Association(Storage = "_people", OtherKey = "LivesInID", Name =
"fk_People_Cities1")]
                [DebuggerNonUserCode]
                public EntitySet<People> People_LivesInID
                {
                        get
                        {
                                return _people;
                        }
                        set
                        {
                                _people = value;
                        }
                }


                #endregion

                #region Attachement handlers

                private void People_Attach(People entity)
                {
                        entity.Cities = this;
                }

                private void People_Detach(People entity)
                {
                        entity.Cities = null;
                }

                private void People_Attach(People entity)
                {
                        entity.Cities = this;
                }

                private void People_Detach(People entity)
                {
                        entity.Cities = null;
                }


                #endregion

                #region ctor

                public Cities()
                {
                        _people = new EntitySet<People>(People_Attach, 
People_Detach);
                        _people = new EntitySet<People>(People_Attach, 
People_Detach);
                }

                #endregion

        }

        [Table(Name = "citypeople.people")]
        public partial class People : INotifyPropertyChanged
        {
                #region INotifyPropertyChanged handling

                public event PropertyChangedEventHandler PropertyChanged;

                protected virtual void OnPropertyChanged(string propertyName)
                {
                        if (PropertyChanged != null)
                        {
                                PropertyChanged(this, new 
PropertyChangedEventArgs(propertyName));
                        }
                }

                #endregion

                #region int BornInID

                private int _bornInID;
                [DebuggerNonUserCode]
                [Column(Storage = "_bornInID", Name = "BornIn_ID", DbType = 
"int",
IsPrimaryKey = true, CanBeNull = false)]
                public int BornInID
                {
                        get
                        {
                                return _bornInID;
                        }
                        set
                        {
                                if (value != _bornInID)
                                {
                                        _bornInID = value;
                                        OnPropertyChanged("BornInID");
                                }
                        }
                }

                #endregion

                #region int ID

                private int _id;
                [DebuggerNonUserCode]
                [Column(Storage = "_id", Name = "ID", DbType = "int", 
IsPrimaryKey =
true, IsDbGenerated = true, CanBeNull = false)]
                public int ID
                {
                        get
                        {
                                return _id;
                        }
                        set
                        {
                                if (value != _id)
                                {
                                        _id = value;
                                        OnPropertyChanged("ID");
                                }
                        }
                }

                #endregion

                #region string LastName

                private string _lastName;
                [DebuggerNonUserCode]
                [Column(Storage = "_lastName", Name = "LastName", DbType = 
"varchar
(45)")]
                public string LastName
                {
                        get
                        {
                                return _lastName;
                        }
                        set
                        {
                                if (value != _lastName)
                                {
                                        _lastName = value;
                                        OnPropertyChanged("LastName");
                                }
                        }
                }

                #endregion

                #region int LivesInID

                private int _livesInID;
                [DebuggerNonUserCode]
                [Column(Storage = "_livesInID", Name = "LivesIn_ID", DbType = 
"int",
IsPrimaryKey = true, CanBeNull = false)]
                public int LivesInID
                {
                        get
                        {
                                return _livesInID;
                        }
                        set
                        {
                                if (value != _livesInID)
                                {
                                        _livesInID = value;
                                        OnPropertyChanged("LivesInID");
                                }
                        }
                }

                #endregion

                #region Parents

                private EntityRef<Cities> _cities;
                [Association(Storage = "_cities", ThisKey = "BornInID", Name =
"fk_People_Cities", IsForeignKey = true)]
                [DebuggerNonUserCode]
                public Cities Cities_BornInID
                {
                        get
                        {
                                return _cities.Entity;
                        }
                        set
                        {
                                if (value != _cities.Entity)
                                {
                                        if (_cities.Entity != null)
                                        {
                                                var previousCities = 
_cities.Entity;
                                                _cities.Entity = null;
                                                
previousCities.People.Remove(this);
                                        }
                                        _cities.Entity = value;
                                        if (value != null)
                                        {
                                                value.People.Add(this);
                                                _bornInID = value.ID;
                                        }
                                        else
                                        {
                                                _bornInID = default(int);
                                        }
                                }
                        }
                }

                private EntityRef<Cities> _cities;
                [Association(Storage = "_cities", ThisKey = "LivesInID", Name =
"fk_People_Cities1", IsForeignKey = true)]
                [DebuggerNonUserCode]
                public Cities Cities_LivesInID
                {
                        get
                        {
                                return _cities.Entity;
                        }
                        set
                        {
                                if (value != _cities.Entity)
                                {
                                        if (_cities.Entity != null)
                                        {
                                                var previousCities = 
_cities.Entity;
                                                _cities.Entity = null;
                                                
previousCities.People.Remove(this);
                                        }
                                        _cities.Entity = value;
                                        if (value != null)
                                        {
                                                value.People.Add(this);
                                                _livesInID = value.ID;
                                        }
                                        else
                                        {
                                                _livesInID = default(int);
                                        }
                                }
                        }
                }


                #endregion

                #region ctor

                public People()
                {
                        _cities = new EntityRef<Cities>();
                        _cities = new EntityRef<Cities>();
                }

                #endregion

        }
}
#########################################################
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DbLinq" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/dblinq?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to