I have problem with id Char(5) as a primary key, where the project need me to make the id with some combination of number and character. example P0001, when new data's inserted, the PK of the new data is P0002 and soon.
Can someone help me with the code? I know about the logic, but I don't know how to get the data from database using linq.
context = new CarRentalLinqDataContext();
Car car = new Car();
car.carName = textBox_CarName.Text;
int year = Int32.Parse(textBox_CarYear.Text);
car.carYear = year;
var id = context.Cars.Max(x => car.car_id);
id = id.Substring(id.LastIndexOf(car.car_id));
int i = Convert.ToInt32(id); i += 1;
string Code = "C000" + i.ToString();
car.car_id = Code; context.Cars.InsertOnSubmit(car);
context.SubmitChanges();