public IEnumerable <BiometricUser> SearchItem(string searchItem, string category, SearchStyleEnum searchStyle) { var query = @"SELECT b.Id, b.BiometricId , p.Id PersonId, [Lastname], [Firstname], [Middlename], [MiddleInitial], [NameExtension], [MaidenMiddlename], [Gender], Category from person p inner join Biometric_User b on p.Id = b.PersonId where Category = '@Category' and Replace(DBO.FULLNAME(LASTNAME, FIRSTNAME, MIDDLENAME, MiddleInitial, 0, NAMEEXTENSION),' ','') like @Criteria"; query = query.Replace("@Category", category); var results = Search.SearchData <dynamic>(searchItem, query, searchStyle); var itemCollection = new List <BiometricUser>(); foreach (var result in results) { var item = new BiometricUser(); item.Map(result); item.PersonClass.DataMapper.Map(result); item.PersonClass.Id = result.PersonId; item.StartTrackingChanges(); itemCollection.Add(item); } return(itemCollection); }
public BiometricUser GetBasicInfoForSmsOf(int biometricId) { var query = @"Select b.BiometricId, b.Category, b.PhoneNumber , Lastname, Firstname, Middlename, MiddleInitial, NameExtension, MaidenMiddlename , gender, CameraCounter from Biometric_User b inner join Person p on p.id = b.PersonId where BiometricId = @BiometricId"; using (var db = Connection.CreateConnection()) { db.Open(); var result = db.Query(query, new { BiometricId = biometricId }).FirstOrDefault(); if (result == null) { return(null); } var item = new BiometricUser(); item.Map(result); item.PersonClass.DataMapper.Map(result); item.StartTrackingChanges(); return(item); } }