/// <summary>
 /// Deprecated Method for adding a new object to the Locations EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToLocations(Location location)
 {
     base.AddObject("Locations", location);
 }
        public Segment CreateSegment(string name, IPAddress subnetMask, IPAddress gateway, Vlan vlan, Location location)
        {
            var subnetMaskArray = subnetMask.GetAddressBytes();
            var gatewayArray = gateway.GetAddressBytes();

            var segment = db.Segments.SingleOrDefault(x => x.Gateway.Address == gatewayArray && x.SubnetMask.Address == subnetMaskArray);

            if (segment == null)
            {
                segment = new Segment
                {
                    Name = name,
                    SubnetMask = CreateIP(subnetMask),
                    Gateway = CreateIP(gateway),
                    Vlan = vlan,
                    IPGroup = GetIPGroup(gateway)
                };

                db.Segments.AddObject(segment);

                var segmentLocation = new SegmentLocation
                {
                    Segment = segment,
                    Location = location
                };

                db.SegmentLocations.AddObject(segmentLocation);
            }

            return segment;
        }
 /// <summary>
 /// Create a new Location object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 public static Location CreateLocation(global::System.Int32 id, global::System.String name)
 {
     Location location = new Location();
     location.Id = id;
     location.Name = name;
     return location;
 }
        public Location CreateLocation(string locationName)
        {
            var location = db.Locations.SingleOrDefault(x => x.Name.Equals(locationName, StringComparison.CurrentCultureIgnoreCase));

            if (location == null)
            {
                location = new Location
                {
                    Name = locationName
                };

                db.Locations.AddObject(location);
            }

            return location;
        }