//Tien public string GenerateCode() { var code = "N" + TextExpress.Randomize(6, TextExpress.NUMBER + TextExpress.NUMBER); var existing = dao.Query(x => x.NoteCode == code).FirstOrDefault(); while (existing != null) { code = "N" + TextExpress.Randomize(6, TextExpress.NUMBER + TextExpress.NUMBER); existing = dao.Query(x => x.NoteCode == code).FirstOrDefault(); } return(code); }