Informacija apie WEB technologijas: ASP.NET, C#, PHP, ASP, CSS, JavaScript, JQuery, SEO.
2012 m. kovo 20 d., antradienis
LINQ to SQL model
1. Prisidėti papildomą projekta "Class library"
2. Pridėti LINQ to SQL model ir jį sukonfiguruoti
3. Konfiguruojant keisti namespace ir sutvarkyti connection string
4. Sukūrus projektą, jį dar reikia pridėti prie web projekto
5. Į web.config įdedame
< add name="DiscountDB" connectionString="Data Source=aaa;Initial Catalog=bbb;Persist Security Info=True;User ID=ccc;Password=ddd" providerName="System.Data.SqlClient"/>
<assemblies>
<
add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</
assemblies>
6. Galiausiai galime naudoti:
Dim odb As New ExportDB.DataContext
Dim obj = From a In odb.MainGroups
7. Sukuriame naują vb failą, konfiguravimui
Namespace My
Partial Friend NotInheritable Class MySettings
Private Sub MySettings_SettingsLoaded(ByVal sender As Object, ByVal e As System.Configuration.SettingsLoadedEventArgs) Handles Me.SettingsLoaded
Me.Item("DiscountConnectionString") = Configuration.ConfigurationManager.ConnectionStrings("DiscountDB").ConnectionString
Me.Item("PriceListConnectionString") = Configuration.ConfigurationManager.ConnectionStrings("PriceListDB").ConnectionString
End Sub
End Class
End Namespace
2. Pridėti LINQ to SQL model ir jį sukonfiguruoti
3. Konfiguruojant keisti namespace ir sutvarkyti connection string
4. Sukūrus projektą, jį dar reikia pridėti prie web projekto
5. Į web.config įdedame
< add name="DiscountDB" connectionString="Data Source=aaa;Initial Catalog=bbb;Persist Security Info=True;User ID=ccc;Password=ddd" providerName="System.Data.SqlClient"/>
<assemblies>
<
add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</
assemblies>
6. Galiausiai galime naudoti:
Dim odb As New ExportDB.DataContext
Dim obj = From a In odb.MainGroups
7. Sukuriame naują vb failą, konfiguravimui
Namespace My
Partial Friend NotInheritable Class MySettings
Private Sub MySettings_SettingsLoaded(ByVal sender As Object, ByVal e As System.Configuration.SettingsLoadedEventArgs) Handles Me.SettingsLoaded
Me.Item("DiscountConnectionString") = Configuration.ConfigurationManager.ConnectionStrings("DiscountDB").ConnectionString
Me.Item("PriceListConnectionString") = Configuration.ConfigurationManager.ConnectionStrings("PriceListDB").ConnectionString
End Sub
End Class
End Namespace
2012 m. kovo 15 d., ketvirtadienis
2012 m. kovo 12 d., pirmadienis
2012 m. kovo 7 d., trečiadienis
LINQ: Join left ir join right
http://www.codeguru.com/columns/vb/article.php/c15057__1/Implementing-a-Left-Join-with-LINQ.htm
Dim sSearch As String = "%" & tbSearch.Text.Trim & "%"
qMoulds = qMoulds.Where(
Function(m) Linq.SqlClient.SqlMethods.Like(m.MouldNo, sSearch) Or
Linq.SqlClient.
SqlMethods.Like(m.MaterialCode, sSearch) Or
Linq.SqlClient.
SqlMethods.Like(m.ProductDrg, sSearch) Or
Linq.SqlClient.
SqlMethods.Like(m.Description, sSearch) Or
Linq.SqlClient.
SqlMethods.Like(m.ComponentCode, sSearch))
End If
Dim qMouldIds = From m In qMoulds
Select m.MouldNo
Distinct
Dim qCurrMoulds = From m In oDB.TTSMoulds
Join l In oDB.TTSLocations On m.LocationID Equals l.ID
Join s In oDB.TTSStores On l.StoreID Equals s.ID
Select m.MouldID, l.Location, s.StoreName
Dim qMouldInfo = From c In qMouldIds
Group Join m In qCurrMoulds On c Equals m.MouldID Into mgroup = Group
From cm In mgroup.DefaultIfEmpty()
Order By c
Select New MouldInfo With {
.MouldNo = c,
.Location = cm.Location,
.StoreName = cm.StoreName
}
Dim sSearch As String = "%" & tbSearch.Text.Trim & "%"
qMoulds = qMoulds.Where(
Function(m) Linq.SqlClient.SqlMethods.Like(m.MouldNo, sSearch) Or
Linq.SqlClient.
SqlMethods.Like(m.MaterialCode, sSearch) Or
Linq.SqlClient.
SqlMethods.Like(m.ProductDrg, sSearch) Or
Linq.SqlClient.
SqlMethods.Like(m.Description, sSearch) Or
Linq.SqlClient.
SqlMethods.Like(m.ComponentCode, sSearch))
End If
Dim qMouldIds = From m In qMoulds
Select m.MouldNo
Distinct
Dim qCurrMoulds = From m In oDB.TTSMoulds
Join l In oDB.TTSLocations On m.LocationID Equals l.ID
Join s In oDB.TTSStores On l.StoreID Equals s.ID
Select m.MouldID, l.Location, s.StoreName
Dim qMouldInfo = From c In qMouldIds
Group Join m In qCurrMoulds On c Equals m.MouldID Into mgroup = Group
From cm In mgroup.DefaultIfEmpty()
Order By c
Select New MouldInfo With {
.MouldNo = c,
.Location = cm.Location,
.StoreName = cm.StoreName
}
2012 m. kovo 5 d., pirmadienis
2012 m. kovo 2 d., penktadienis
MaintainScrollPositionOnPostBack
Savybė, po Postback grąžinanti į redaguojamą puslapio vietą:
MaintainScrollPositionOnPostBack = True
MaintainScrollPositionOnPostBack = True
žymės:
ASP.NET,
MaintainScrollPositionOnPostBack,
VB
Užsisakykite:
Pranešimai (Atom)