Friday, 15 February 2013

c# - Building a Raw SQL String from Linq Query Results? -


I have to make a selection from a SQL Server table and add the results to a SQL string so that I var sqlString = "Select Blama by Blah Blah from Black" :

Enter image details here

Here's my LINQ. I am trying to select the columns for which I need them & amp; Align them to 1 string:

  var query = (_Context.tbArticleTypeAssets where a.ArticleType == Select articleType new {sqlQuery = a.ColSelection + "+ + a.FromTable + "" + .whereclause + "" + a.orderBY}); String queryRezalt = query.ToString ();  

The result is a Linq output that I do not want. I just want the values ​​of stars. Is there any way to get it?

The linux query will return an archive, you must first () or First and default () to get the item:

  string query sage = query.FirstOrDefault (). SqlQuery;  

Better is also a null check:

  string query result = query.FirstOrDefault ()! = Null? Query.FirstOrDefault (). SqlQuery: string.Empty;  

No comments:

Post a Comment