是否有任何解决方案可以在linq查询中动态传递表名。列名在不同的表中相同 [英] Is there any solution to pass table name dynamically in linq query . Column name are same in different table

查看:76
本文介绍了是否有任何解决方案可以在linq查询中动态传递表名。列名在不同的表中相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要动态传递表名,例如循环或其他条件。





实际上有两到三个表具有相同的结构。如果我想更新意味着我必须为每个表写单独的更新查询。查询之间的区别仅在于表名。如果在单个查询中动态传递表名的任何可能性意味着我可以在单个查询中保存具有相同结构和列的不同表。不仅要更新以从这些表中获取价值



我尝试过:



我尝试过declare context.tablename并在linq查询中使用。但它不起作用。有没有解决方案

I need to pass the table name dynamically for example by loop or other conditions.


Actually there is tow to three tables with same structure . If i want to update means i have to write separate update query for each table . The difference between the query is only the table name . If any possibilities to pass table name dynamically in single query means i can save different table with same structure and columns in single query . Not only for update to get value from those tables also

What I have tried:

I have tried by declare context.tablename and used in linq query . But its not working . Is there any solution

推荐答案

检查一下: c# - linq中的动态表名 - 堆栈溢出 [ ^ ]


这篇关于是否有任何解决方案可以在linq查询中动态传递表名。列名在不同的表中相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆