

Operator linq as * (asterisk) in sql
source link: https://www.codesd.com/item/operator-linq-as-asterisk-in-sql.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Operator linq as * (asterisk) in sql
I want to select all the fields of one table, and only specifics fields of a second table. Are there any way to do it like with table.* in SQL?
var things = from t in db.table1
from t2 in db.table2
where ...Join Clause...
select new { t.*,t2.onefield}
obviously this code don't work, but I think it ilustrate my pourpose.
if I use
select new {t,t2.onefield}
it compiles, but it fails when I assign it to a datasource of a datagridview. Currently I'm writing every field that I need of every table.
Thanks.
That isn't good practice in SQL and, even if it can be done with Linq, wouldn't be good practice with Linq either, unless Linq would generate T-SQL code that expands to all the columns of the table.
Related Articles
Is this LINQ statement vulnerable to SQL injection?
String concatenation operator in Oracle, Postgres, and SQL Server
What type of operation invoked a trigger in SQL Server 2008?
Why did not the designers of LINQ adopt the way SQL is written today?
Please help me convert a Linq query to a SQL & hellip; Desperate
Operator Linq-To-SQL .ToList ()
How to use c # to perform summation operations with type conversion from SQL using LINQ
Linq where faster than SQL where
LINQ equivalent of my SQL query for UNION ALL
VS LINQ Entity Framework to SQL VS ADO.NET with Stored Procedures?
LINQ, Skip, OrderBy, and SQL Server 2000
Linq Query for Corresponding SQL
What is the easiest way to find the LINQ statement for an SQL statement
Can I use Linq with View of sql server?
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK