c# - Entity Framework multiple search with empty variables? -
I want to find many and want to get results. I send this function Sometimes I can fill up the And as Mihai suggested that you can add to all the stories. the 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 = "";
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 ();
Comments
Post a Comment