Last post Feb 10, 2015 04:53 AM by Zhi Lv - MSFT
Feb 10, 2015 12:03 AM|Shibly|LINK
I've two table in my database and the table are User(userID, SttngName, AppName), UserLanguage(ID, userIDRef, tblName, tblField, language, LngSttng). In UserLanguage table I've store the language for the each property of the User table individually. Like
SttngName property have a language row in UserLanguage table; AppName property have the same row in UserLanguage table. In the UserLanguage table I've several language stored like EN(English), Bn(Bengali), Dt(German), NL(The Netherlands), Ru(Russian). Now
I want to show the language data when user change their language setting En to NL or NL to Dt. The problem is I don't understand how I can get the language data from database I can't find any logic in sql or in linq. Can anyone help me please.
Thanks in advance.
Feb 10, 2015 12:37 AM|prakher_prakher|LINK
Create a procedure which accepts the language as a parameter.
In the procedure, create dynamic sql by using table, field and user details fetched from the UserLanguage table as per the language value passed in as parameter.
Execute the dynamic sql using sp_executesql.
Feb 10, 2015 04:53 AM|Zhi Lv - MSFT|LINK
The problem is I don't understand how I can get the language data from database I can't find any logic in sql or in linq. Can anyone help me please.
From your description, I suppose you want to get all kind of languages from UserLanguage table. If that is the case, you could try to use
distinct key word or method. Like this:
In SQL: select Distinct [language] from UserLanguage
using (Database1Entities context = new Database1Entities())
var query2 = (from cc2 in context.UserLanguages
foreach( var qq in query2)
ListItem item =new ListItem();
item.Text = qq;
item.Value = qq;