MonkeyWrench.DB.GetLanesForHost C# (CSharp) Method

GetLanesForHost() public method

public GetLanesForHost ( int host_id, bool only_enabled ) : List
host_id int
only_enabled bool
return List
		public List<DBLane> GetLanesForHost (int host_id, bool only_enabled)
		{
			List<DBLane> result = new List<DBLane> ();

			using (IDbCommand cmd = CreateCommand ()) {
				cmd.CommandText = "SELECT *, HostLane.host_id AS host_id, HostLane.enabled AS lane_enabled FROM Lane INNER JOIN HostLane ON Lane.id = HostLane.lane_id WHERE host_id = @host_id ";
				if (only_enabled)
					cmd.CommandText += " AND HostLane.enabled = true;";
				DB.CreateParameter (cmd, "host_id", host_id);
				using (IDataReader reader = cmd.ExecuteReader ()) {
					while (reader.Read ()) {
						result.Add (new DBLane (reader));
					}
				}
			}

			return result;
		}