asp.net mvc 3 - Using mvc3, I need to add a username/password to the sql connection string at runtime -
i see how build string using stringbuilders (sql/entity framework); do cause connection string used in dbcontext?
example context:
public class pophistorydbcontext : dbcontext { public dbset<pophistory> histories {get;set} } public class pophistoryrepository: ihistoryrepository { private pophistorydbcontext context = new pophistorydbcontext(); public iqueryable<pophistory> histories{ {return context.histories;} } }
example usage in controller:
public class historycontroller : controller { private ihistoryrepository repository = new pophistoryrepository(); var histories = h in repository.histories (h.modifytimestamp > today) select h; if (!string.isnullorempty(searchstring)) { histories = histories.where(h => h.dn.toupper().contains(searchstring.toupper())); }
thank you
Comments
Post a Comment