LinqToEntitiesDomainService Dynamic Binding DataBase ,Silverlight RIA 动态绑定数据库
2011-02-17 15:01
423 查看
手上有个搜索引擎的项目,每个行业都有一个独立的数据库,这些数据库schemas都是一样。这样RIA就需要根据客户选择的不同行业连接到不同的数据库。解决办法参看 链接
这个方法不是最理想的,大致代码如下
在silverlight端
[/code]
这个方法不是最理想的,大致代码如下
在silverlight端
private void SetCookie(string cookieName, string cookieValue) { DateTime expireDate = DateTime.Now + TimeSpan.FromDays(1); string newCookie = cookieName + "=" + cookieValue + ";expires=" + expireDate.ToString("R"); HtmlPage.Document.SetProperty("cookie", newCookie); } 在RIA端override
protected override ProjectEntities CreateObjectContext() { long projectId = -1; StringBuilder connection; if (System.Web.HttpContext.Current.Request.Cookies["SelectedProjectId"] != null) { projectId = Convert.ToInt64(System.Web.HttpContext.Current.Request.Cookies["SelectedProjectId"].Value); } else throw new Exception("Selected Project ID Exception"); // temporary // Verify this user has access to the DB just in case it's spoofed // Lookup project ID in my database to get the database name and server name // Load template connection string found in web.config // Replace the template holders for SERVER_NAME and DATABASE_NAME with above lookup values return new ProjectEntities(MyDynamicConnectionString); }
[/code]
相关文章推荐
- Linq To SQL + .NET Ria Service Beta + Silverlight 3 部署过程
- 在IIS部署Silverlight应用和WCF RIA Services,出现异常:未能加载文件或程序集“System.ServiceModel.DomainServices.Hosting, Ver
- Silverlight WCF RIA服务(九)Domain Service 2
- 用 linq to sql+wcf service+datagrid 创建基本的silverlight2.0应用程序
- Silverlight中RIA Domain Service处理Relational Data
- Silverlight中RIA Domain Service处理Relational Data
- 使用Entity Framework和WCF Ria Services开发SilverLight之7:多个Domain Service间共享Poco实体
- Silverlight WCF RIA服务(九)Domain Service 2
- SilverLight中使用WCF Ria出现的问题empty domain service class
- RIAService客户端 对linq 外键对象排序【silverlight】
- 使用Entity Framework和WCF Ria Services开发SilverLight之7:多个Domain Service间共享Poco实体
- 使用Entity Framework和WCF Ria Services开发SilverLight之7:多个Domain Service间共享Poco实体
- Binding a Silverlight DataGrid to dynamic data via IDictionary
- Uploading large files to database with Silverlight/WCF
- LINQ to Entities 查询注意事项
- 在silverlight中使用Linq TO XML
- Linq To Entities中的动态排序
- Silverlight之Ria Service访问存储过程
- Silverlight中服务通信方式的选择(WCF、Data Service、Ria Service)
- The specified type member 'Date' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.