c# - Entity Framework multiple search with empty variables? -


I want to find many and want to get results. I send this function devicename user alarm When these variables are filled, then it works. But when they are empty, it is not so. I can only fill the devicename variable for example;

  devicename = "test"; Alarm = ""; User = "";   

Sometimes I can fill up the devicename user , sometimes I devicename Alarms .. I can not get any data from my code. I need help Here is my code:

  list & lt; Activity log & gt; List = db.ActivityLog.Where (C => c.Devices.devName.ToLower (). Includes (devicename.ToLower ()). Where (c = & gt; c.users.uName.ToLower (). Contains (user. Taylor ()). Where (C => c.AlarmCodes.aName.ToLower (). Includes (alarm. ToLower ()). Order By (C => CDATime). Take Skip (Skip) (pageSize) .ToList ();    

  list & lt; activity log & gt; list = Db.ActivityLog.Where (C => devicename == "" || c.Devices.devName.ToLower () contains it (devicename.ToLower ()). Where (C => User == "C" (C => Alarm == "" || c.AlarmCodes.aName.ToLower (). It contains (alarm. ToLower ()). OrderBe (C = & gt; CDATime). Leaving (Skip ). Move (Page Size). St ();   

And as Mihai suggested that you can add to all the stories. the

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -