dimanche 22 février 2015

how to test split char test to search?

Hi I'm trying to create select search to to find people by fistname or lastName but when the user type search for name I have couple of cases



  1. fullName String ex"john"

  2. fullName contains split char "." ex:john.dow

  3. fullName contains split char "_" ex:john_dow

  4. fullName contains split char " " ex:john dow


my problem is if always run the first case my Question how can I make my code run the right case C#



using System;

namespace separatefullnamestring
{
class MainClass
{
public static void Main (string[] args)
{
string qurey = "fulname.kkkkk";


// var result = from tableA in ContextDB.tblA
// join tableB in ContextDB.tblb tableA. ID equals tableB.ID
// select tableA;
//

//String.isNullOrEmpty(qurey)
if (!String.IsNullOrEmpty (qurey)) {
Console.WriteLine ("fullname ");
//result = result.where(p => p.FirstName.containe(qurey) || p.LastName.containe(qurey));

} else // if full name contine containe . firstName.LastName
if (qurey.Contains (".")) {
Console.WriteLine ("Contains .");
// var names = fullName.Split ('.');
// string fName = names[0];
// string lName = names[1];
// result = result.where(p => p.FirstName.containe(fName) || p.LastName.containe(lName));

} else // if full name contine containe _ firstName_LastName
if (qurey.Contains ("_")) {
Console.WriteLine ("Contains .");
// var names = fullName.Split ('_');
// string fName = names[0];
// string lName = names[1];
// result = result.where(p => p.FirstName.containe(fName) || p.LastName.containe(lName));

} else // if full name contine containe space firstName_LastName
if (qurey.Contains (" ")) {
Console.WriteLine ("Contains ");
//var names = fullName.Split ('_');
//string fName = names[0];
//string lName = names[1];
//result = result.where(p => p.FirstName.containe(fName) || p.LastName.containe(lName));

}



}
}
}

Aucun commentaire:

Enregistrer un commentaire