如何从两个连接字符串中进行选择?
下午好,我遇到了使用 C# 和 Linq to Entities 从两个连接字符串中进行选择的问题。目前我有两个连接字符串:
<add name="GameHutDBEntities1" connectionString="metadata=res://*/GameHutModel.csdl|res://*/GameHutModel.ssdl|res://*/GameHutModel.msl;provider=System.Data.SqlClient;provider connection string="Data Source=EMMANUEL-PC\SQLEXPRESS;Initial Catalog=GameHutDB;user id=GameHutAdmin; password=123;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
<add name="GameHutDBEntities2" connectionString="metadata=res://*/GameHutModel.csdl|res://*/GameHutModel.ssdl|res://*/GameHutModel.msl;provider=System.Data.SqlClient;provider connection string="Data Source=EMMANUEL-PC\SQLEXPRESS;Initial Catalog=GameHutDB;user id=test; password=1234;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
我有两个角色,即管理员和职员。如何允许管理员使用第一个连接字符串登录,而职员使用第二个连接字符串登录?
Good afternoon, I have encountered a problem to choose from two connection strings using C# and Linq to Entities. Currently I have two connection strings which are:
<add name="GameHutDBEntities1" connectionString="metadata=res://*/GameHutModel.csdl|res://*/GameHutModel.ssdl|res://*/GameHutModel.msl;provider=System.Data.SqlClient;provider connection string="Data Source=EMMANUEL-PC\SQLEXPRESS;Initial Catalog=GameHutDB;user id=GameHutAdmin; password=123;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
<add name="GameHutDBEntities2" connectionString="metadata=res://*/GameHutModel.csdl|res://*/GameHutModel.ssdl|res://*/GameHutModel.msl;provider=System.Data.SqlClient;provider connection string="Data Source=EMMANUEL-PC\SQLEXPRESS;Initial Catalog=GameHutDB;user id=test; password=1234;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
I have two roles which are Admin and Clerk. How can I allow the admin to login with the first connection string and the clerk will login with the second connection string?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
改编自这个答案:
其中
IsAdmin
是一个采用用户 如果他是管理员则返回 true,否则返回 false。
Adapted from this answer:
Where
IsAdmin
is a function taking auser
and returning true if he is an admin and false if not.