Wednesday, October 10, 2012
a little rememberence about dotNet Extension Methods
Extension methods are defined as static methods but are called by using
instance method syntax. Their first parameter specifies which type the
method operates on, and the parameter is preceded by the this modifier. Extension methods are only in scope when you explicitly import the namespace into your source code with a using directive.
Sunday, September 30, 2012
Code Snippet
to select a ASP.Net Grid Row by click
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
try
{
if(e.Row.RowType == DataControlRowType.DataRow )
e.Row.Attributes.Add(
"onclick",
Page.ClientScript.GetPostBackEventReference(sender as Control, @"Select$" + e.Row.RowIndex.ToString())
) ;
...
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
try
{
if(e.Row.RowType == DataControlRowType.DataRow )
e.Row.Attributes.Add(
"onclick",
Page.ClientScript.GetPostBackEventReference(sender as Control, @"Select$" + e.Row.RowIndex.ToString())
) ;
...
Friday, September 28, 2012
SSMS Tools Pack
SSMS Tools Pack is an add-in for Microsoft SQL Server Management Studio (SSMS) 2005,
2008, 2008 R2, 2012 and their respective Express versions.
It contains a few upgrades to the SSMS IDE that I thought were missing.
To see what's new and what got fixed in a release check the News page.
The current features include:
It contains a few upgrades to the SSMS IDE that I thought were missing.
To see what's new and what got fixed in a release check the News page.
The current features include:
- Execution Plan Analyzer
- SQL Snippets
- Window Connection Coloring
- Window Content History, Query Execution History, Current Window History and Tab Sessions
- Format SQL
- Search Table, View or Database Data
- Run one script on multiple databases
- Copy execution plan bitmaps to clipboard or file
- Search Results in Grid Mode
- Generate Insert statements from resultsets, tables or database
- Regions and Debug sections
- Running custom scripts from Object Explorer
- CRUD stored procedure generation
- New query template
- General options
Wednesday, September 19, 2012
Windows Azure Platform : AppFabric
The Windows Azure platform represents a radical change in the way applications can be
built and managed. This platform provides an Internet - based cloud computing environment
that anyone can use for hosting applications and storing the associated data. The platform
in general comprises two core services that any cloud - based application can use: compute
(e.g., executing an application) and storage (e.g., storing data on disk).
The compute service enables any application to run in the cloud. In essence, the applications
are deployed in a highly scalable environment where they share computer processor time
available in different virtual machines with Windows Server. These virtual machine
instances are spread around the world in different Microsoft data centers.
The storage service, as its name clearly states, provides simple storage capabilities using
different schemas such as BLOBs (binary objects), queues, or simple tables through a very
easy - to - use REST API based on Http calls. In case an application requires richer querying
capabilities for the storage (e.g., relational databases), an additional service, SQL Azure, is
also provided by Microsoft in this platform.
In both cases, Windows Azure assures the availability and high scalability that any
cloud - based application requires.
AppFabric extends the Windows Azure platform by providing two common building blocks,
the Service Bus and Access Control, to make it easier to extend the reach of any .NET applications in this platform. They currently provide key functionality to support bi - directional
connectivity and federated claims - based access control in any application trying to migrate to
Windows Azure.
The primary feature of the Service Bus is to “ route ” messages from clients through the Windows
Azure cloud to your software running on - premise, bypassing any NAT, fi rewalls, or other network
obstacles that might be in the way. In addition to routing messages, the Service Bus can also help
negotiate direct connections between applications.
The primary feature of Access Control is to provide a claims - based access control mechanism
for applications running on - premises or on the cloud. This makes federated authentication and
authorization much easier to achieve, allowing third - party applications to trust identities provided
by other systems.
Although each of these building blocks is available using open protocols and standards such as
REST, Atom/AtomPub, and SOAP, Microsoft has also provided a SDK that simplifi es the work
for .NET developers by hiding many of the wire protocol complexities that they would otherwise
experience when working with them directly. As part of this SDK, you can take advantage of some
of the new WCF extensions. These include the relay bindings, to talk to the Service Bus, or custom
authorization managers for parsing the security tokens generated by the Access Control.
Tuesday, August 7, 2012
something like Dot Net LINQ in Java : JOOOQ
jOOQ : A peace treaty between SQL and Java
SQL was never meant to be abstracted. To be confined in the narrow boundaries
of heavy mappers, hiding the beauty and simplicity of relational data.
SQL was never meant to be object-oriented. SQL was never meant to be
anything other than... SQL!
It's simple. With the jOOQ DSL, SQL looks almost as if it were
natively supported by Java. For instance, get all books published in 2011, ordered by title
create.selectFrom(BOOK)
.where(PUBLISHED_IN.equal(2011))
.orderBy(TITLE)
jOOQ also supports more complex SQL statements. get all authors' first and last names, and the number of books they've written in German, if they have written more than five books in German in the last three years (from 2011), and sort those authors by last names limiting results to the second and third row, then lock first and last names columns for update
http://www.jooq.org/
How to add custom unbound property to LINQ2SQL , EF
We encountered this error because we did not map entity property OrganizationName to certain table column in the database. You can check the table mapping by right click the entity User and select “Table Mapping”.
However, I don’t think we can solve the problem by only adding a custom property in the designer. Even we add the Organization table in the Mapping Details and map the OrganizationName property to Organization.Name column, EF still wants us to map the PK of the Organization table to one property in the User entity. But the FK property of User entity is not Entity Key, so the entire mapping still fails. Hope I made it clear to understand.
To workaround, I would recommend you to write some hard code to add a custom property into the User class. Since all the entity classes are partial classes, we can create a new partial User class and add the custom property outside the EDM designer:
==========================================================================
public partial class User
{
public string OrganizationName
{
get
{
if (this.Organization != null)
return this.Organization.Name;
else
else
return string.Empty;
}
set
{
if (this.Organization != null)
this.Organization.Name = value;
}
}
}
==========================================================================
BTW, I should mention the lazy loading feature of EF4 which is not available in EFv1. That mentions the related entities will not be loaded until we try to access them. If this case, if we turn off the lazy loading feature by (context.ContextOptions.LazyLoadingEnabled = false), we need to add such a filter in the getter/setter of property OrganizationName:
==========================================================================
if (!this.OrganizationReference.IsLoaded)
{
{
this.OrganizationReference.Load();
}
==========================================================================
Additional reference about lazy loading in EF4:http://geekswithblogs.net/iupdateable/archive/2009/11/26/getting-started-with-entity-framework-4-ndash-lazy-loading.aspx.
Monday, August 6, 2012
C# Open WPF window in WindowsForm APP
using System;
using System.Windows.Forms;
using System.Windows.Forms.Integration;
var wpfwindow = new WPFWindow.Window1();
ElementHost.EnableModelessKeyboardInterop(wpfwindow);
wpfwindow.Show();
you need to add project reference to WindowsFormsIntegration.dll
Subscribe to:
Posts (Atom)