How can I fatch data from database for AutoComplete textbox

Hello!
I want to fetch data from mysql database for AutoComplete textbox and store that data into database. 

1 Reply

PM Ponmani Murugaiyan Syncfusion Team May 21, 2020 02:54 AM UTC

Hi Ishan,  

Greetings from Syncfusion support.  

We rendered the AutoComplete component by loading the data from SQL database. Kindly refer the below code and test sample for your reference,  

public List<Departments> DepartmentList()  
        {  
            return _context.Departments.Select(u => new Departments  
            {  
                Id = u.Id,  
                DepartmentName = u.DepartmentName  
            }).ToList();  
        }  
private readonly IJobService _jobService;  
        public HomeController(IJobService jobService)  
        {  
            _jobService = jobService;  
        }  
  
        public IActionResult GetDepartments()  
        {  
            return new JsonResult(_jobService.DepartmentList());      
        }  

We get the value from the SQL DataBase from the context.  

  protected override void OnModelCreating(ModelBuilder modelBuilder)  
        {  
            modelBuilder.Entity<Departments>(entity =>  
            {  
                entity.Property(e => e.DepartmentName).HasMaxLength(50);  
            });  
  
            OnModelCreatingPartial(modelBuilder);  
        }  
  
  
Regards,  
Ponmani M  


Loader.
Up arrow icon