/// <summary>
 /// Create a new IPGroup object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="iPId">Initial value of the IPId property.</param>
 /// <param name="subnetMaskId">Initial value of the SubnetMaskId property.</param>
 public static IPGroup CreateIPGroup(global::System.Int32 id, global::System.String name, global::System.Int32 iPId, global::System.Int32 subnetMaskId)
 {
     IPGroup iPGroup = new IPGroup();
     iPGroup.Id = id;
     iPGroup.Name = name;
     iPGroup.IPId = iPId;
     iPGroup.SubnetMaskId = subnetMaskId;
     return iPGroup;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the IPGroups EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToIPGroups(IPGroup iPGroup)
 {
     base.AddObject("IPGroups", iPGroup);
 }
        public IPGroup CreateIPGroup(string name, IPAddress ipAddress, IPAddress subnetMask)
        {
            var group = db.IPGroups.SingleOrDefault(x => x.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase));

            if(group == null)
            {
                group = new IPGroup
                {
                    Name = name,
                    IP = CreateIP(ipAddress),
                    SubnetMask = CreateIP(subnetMask)
                };

                db.IPGroups.AddObject(group);
            }

            return group;
        }