c# - How to use contain clause to query multiple parameters? -


I'm trying (/ api / data? Name = storm, bcam & tag = 78473TAC4,12669VAC2), but This outputing is 'no data response'. Message on client-side
I have tested the same query with SQL and it outputs 10 records. 'Database' from which 'TAG' or '% name like'% STORM% ' like TAG or'% BCAM% ​​'like'% 78473 tac4% 'or'% 01266 9 VAC 2% '

I have tried many different ways to return and add data to the list but I do not keep any 'data' message.

var data = db.database_bd.AsQueryable (); If (query.startDate! = Null) {data = data. Where (c => c.upploadDate> = query.startDate); } If (! String.IsNullOrEmpty (query.name)) {var list = query.name.Split (','); Foreach (string in list) {data = data. Where (C => List. Anyone (a => C. NAME.Contains (i))); }} If (! String.IsNullOrEmpty (query.tag)) {var list = query.tag.Split (','); Foreach (string i in the list) {data = data. Where (C => List. Anyone (a => c.TAG.Contains (i))); }} If (! Data. Any)) {var message = string.Format ("no data found"); Return request. CreteErrorpressPage (HTTTAS code.Notfound, message); } Return request. CreteSpons (HTTTP code.OK, data); }

Any help would be greatly appreciated. Thank you ..

I see a potential bug.

Your second block (filtering on tag) is actually a "filtering out" result if you have already received the block !! Therefore, effectively, you are doing "end" operation which is not what your SQL query is doing.

Effectively, read the blocks two in this way:

  data = data.Where (c => list. (Any => .TAG.Contains (tagArg));  
Any (a => c.NAME.Contains (nameArg)).

Instead, if the blocks have the ideal "basic data" Work should be done and then matches should be merged into "Results Data".

This is what you want. Rite?


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -