this is the query , in which i want default value is Brand should be Maruti
public static string TopSixCarsByBrand(string _brand)
{
var _sql = "SELECT TOP(6)ci.car_ID,ci.user_ID,ci.brand,ci.modelType,ci.expectedPrice,ci.saleCity,ci.totalViews,ci.transmission,ci.modelYear,ci.totalDriven,ci.modelYear,ci.fuelType,ci.color,cd.primaryImage AS primary_Image,cd.imagePath as image_Path FROM CarInfo ci ";
if(!string.IsNullOrEmpty(_brand) && _brand != "All Manufacturers")
{
_sql += "INNER JOIN CarDetail cd ON ci.car_ID=cd.car_ID WHERE ci.brand='" + _brand + "' AND cd.primaryImage=1 AND adContentType='Good' AND (ci.isSold<>1 or ci.isSold is null);";
}
else
{
_sql += "INNER JOIN CarDetail cd ON ci.car_ID=cd.car_ID WHERE cd.primaryImage=1 AND adContentType='Good' AND (ci.isSold<>1 or ci.isSold is null);";
}
return _sql;
}
above query i am using
Sachin SinghPosted May 3, 2022, 12:56 PM
Guest UserPosted May 3, 2022, 12:21 PM
Sachin SinghPosted May 3, 2022, 12:08 PM
Anupam MaitiPosted May 3, 2022, 11:49 AM
You can set default brand value by below way.. This menas while calling this menthod if you didn't pass any brand value , it will consider "Maruti" as default.
public static string TopSixCarsByBrand(string _brand = "Maruti")
If this is resolved your query , please accept this answer.