Profil de JagadishJagadish Pulakhandam'sPhotosBlogListesPlus ![]() | Aide |
|
31 mars Beginning "LINQ to SQL" using Visual Studio 2008Hai,
My new article on "LINQ to SQL" got published here http://www.aspfree.com/c/a/.NET/Beginning-LINQ-to-SQL-Using-Visual-Studio-2008/
It covers all the following topics:
-> Developing a simple "LINQ to SQL" application without using "LINQ to SQL" designer
-> Retrieve and update information using "LINQ to SQL"
-> using DataContext object in LINQ development.
-> Source Code in both Visual Basic and C#
Hope it helps.
thanks
Jag
13 mars TIP: Viewing the generated SQL of LINQ statementsEven though LINQ uses the familar syntax as of SQL, it is not the same SQL generated at run-time. To view the SQL generated from LINQ, we can use "Log" property of "DataContext" in the following manner:
Dim obj As New SampleDAL.SampleDataContext
Dim s As New StringWriter obj.Log = s Me.GridView1.DataSource = From p In obj.emps _ Where p.deptno = 10 _ Select p Me.GridView1.DataBind() Me.Label1.Text = s.ToString You can also make use of VS integrated debugger as shown here
Hope this helps...
thanks,
Jag TIP: Modifying Connection String dynamically for a strongly typed dataset in a different assemblyImagine, I am working on a Visual Studio 2005/2008 solution with class library project (DAL) and Web Application Project (ASP.NET). Say, the DAL is being developed using Dataset Designer with different Strongly Typed DataSets/DataTables together with TableAdapters. Then I would certainly run into a problem.
The DAL (by default) maintains its own connection string in application configuration settings (app.config) and the ASP.NET application maintains its own connection string in Web.config file. Any project, by principle, should not contain connection strings at more than one location.
To make DAL pickup Connection String automatically from web.config by itself (without writing any code) during run-time, simply make sure that the names of connection strings (not the values) are identical in both app.config and web.config.
To make DAL pickup Connection String dynamically from web.config during run-time (at least). It can be easily accomplished by adding the following code to the "MySettings" class in "Setting.Designer.vb" file.
Private Sub MySettings_SettingsLoaded(ByVal sender As Object, ByVal e As System.Configuration.SettingsLoadedEventArgs) Handles Me.SettingsLoaded
Dim s As MySettings = TryCast(sender, MySettings) s.Item("SampleConnectionString") = System.Configuration.ConfigurationManager.ConnectionStrings("cnDev").ConnectionString End Sub To make the above work, you may also need to refer to "System.Configuration" in your class library project.
Hope the above solves the problem...
thanks
Jag
|
|
|