public Result Delete(ClientSpace client)
		{
			Result result = new Result();
			if (OnBeforeDeleteClientSpace != null)
				OnBeforeDeleteClientSpace(client, result);
			SqlConnection conn = null;
			if (result.Succeeded)
			{
				try
				{
					using (TransactionScope scope = new TransactionScope())
					{
						conn = (SqlConnection)DatabaseManager.DatabaseEngine.GetConnection();
						try
						{
							SqlCommand cmd = new SqlCommand("DeleteClientSpace", conn);
							cmd.CommandType = CommandType.StoredProcedure;
							cmd.Parameters.Add(new SqlParameter("@ClientSpaceID", client.ClientSpaceID));
							cmd.ExecuteNonQuery();
							scope.Complete();
						}
						catch (Exception ex)
						{
							return new Result(ex.Message);
						}
					}
					if (OnClientSpaceDeleted != null)
						OnClientSpaceDeleted(client);
				}
				finally
				{
					DatabaseManager.DatabaseEngine.ReleaseConnection(conn);
				}
			}
			return result;
		}
		public ClientSpace SelectClientSpace(long clientSpaceID)
		{
			using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Suppress))
			{
				using (SqlConnection conn = new SqlConnection(DatabaseManager.DatabaseEngine.ConnectionString))
				{
					conn.Open();
					SqlCommand cmd = new SqlCommand("SelectClientSpace", conn);
					cmd.CommandType = CommandType.StoredProcedure;
					cmd.Parameters.Add(new SqlParameter("@ClientSpaceID", clientSpaceID));
					SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
					ClientSpace cs;
					if (!reader.Read())
						cs = null;
					else
						cs = new ClientSpace(reader);
					reader.Close();
					return cs;
				}
			}
		}
		public Result Store(ClientSpace client)
		{
			SqlConnection conn = null;
			try
			{
				using (TransactionScope scope = new TransactionScope())
				{
					conn = (SqlConnection)DatabaseManager.DatabaseEngine.GetConnection();
					try
					{
						SqlCommand cmd = new SqlCommand("StoreClientSpace", conn);
						cmd.CommandType = CommandType.StoredProcedure;
						SqlParameter prm = new SqlParameter("@ClientSpaceID", client.ClientSpaceID);
						prm.Direction = ParameterDirection.InputOutput;
						cmd.Parameters.Add(prm);
						cmd.Parameters.Add(new SqlParameter("@Name", client.Name));
						cmd.Parameters.Add(new SqlParameter("@Enabled", client.Enabled));
						cmd.Parameters.Add(new SqlParameter("@PrimaryUserID", client.PrimaryUserID));
						for (int i = 0; i < cmd.Parameters.Count; i++)
							if (cmd.Parameters[i].Value == null)
								cmd.Parameters[i].Value = DBNull.Value;
						cmd.ExecuteNonQuery();
						client.ClientSpaceID = (long)prm.Value;
						scope.Complete();
					}
					catch (Exception ex)
					{
						return new Result(ex.Message);
					}
				}
			}
			finally
			{
				DatabaseManager.DatabaseEngine.ReleaseConnection(conn);
			}
			return new Result();
		}