Great collection of useful SSAS articles. It helped me. It will help all.
Monday, November 19, 2012
Thursday, October 4, 2012
Insert Object in Office 2013
Office 2013 become much more smart and packed with lot of features, at the same time switching between the version always has some learning curve. Recently we spend few minute in searching the insert object option in 2013.
In Office 2010
Wednesday, September 26, 2012
T-SQL Concatenate all row values
Many time you may need to get list of values from a database table and form a concatenated string (Comma separated). I see still some programmer use cursor to do that. we have simple technique to achieve this.
DECLARE @T VARCHAR(MAX)
SET @T = ''
SELECT @T = @T + COLUMN_NAME + ', '
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'Metadata' AND TABLE_SCHEMA = 'DBO'
SELECT @T
The @T variable will hold all row values separated by comma.
C# Virtual & Abstract Properties
Recently a new learner of C# asked me a question on C# Virtual & Abstract properties. It turned out to a deep dive. Detail follows.
Difference between the Abstract and Virtual property
* Abstract properties forces you to make the class abstract,
no such constraint for virtual properties. Virtual provides
an offer to subclass to override.
* Abstract properties defer the implementation to subclass.
In Virtual property a default implementation can be provided..
Let us deep dive on write only virtual property
-------------------------------------------------------------
To make a property as write only
Option 1: You can mark the getter as private
public virtual string Prop1 { set; private get; }
Option 2: You can just have setter
> in case of explicit implemented properties,
it is legal to just have Setter
/////////////////////////////////////////////////////
string Field;
public virtual string Prop1 { set { Field = value; } }
/////////////////////////////////////////////////////
> in case of Automatically implemented properties, you must have getter
because if you have just the setter, there is no way you can
access the value. (Check compiler error below)
/////////////////////////////////////////////////////
public virtual string Prop1 { set; }
/////////////////////////////////////////////////////
Error:
'ConsoleApplication1.test.MyVirtaulWriteOnlyProperty1.set' must declare a body
because it is not marked abstract or extern. Automatically implemented properties
must define both get and set accessors.
Detail:
So for virtual write only property, you must explicitly have setter implemented.
if you are using Automatically implemented property it must have both get & set
In contrary write only abstract property allows setter only property.
It is because, in abstract the implementation is deferred, in the subclass
the compiler will force you to implement the setter explicitly in subclass.
/////////////////////////////////////////////////////
abstract class Animal
{
public abstract string Prop1 { set; }
}
/////////////////////////////////////////////////////
Attempt - 1
/////////////////////////////////////////////////////
public class Dog : Animal
{
public override string Prop1 {set;}
}
/////////////////////////////////////////////////////
Errror
'ConsoleApplication1.Dog.Prop1.set' must declare a body
because it is not marked abstract or extern.
Automatically implemented properties must define both get and set accessors.
Detail:
The reason is there is no way you can read the value,
so compiler forces us to add both get, set.
Attempt - 2
/////////////////////////////////////////////////////
public class Dog : Animal
{
public override string Prop1 {get;set;}
}
/////////////////////////////////////////////////////
Error:
'ConsoleApplication1.Dog.Prop1.get': cannot override
because 'ConsoleApplication1.Animal.Prop1'
does not have an overridable get accessor
Detail:
There is no getter defined in suberclass, so we cannot define it in subclass.
We cannot change the write only property as read/write property in subclass
Attempt - 3: (Correct implementation)
/////////////////////////////////////////////////////
public class Dog : Animal
{
string field;
public override string Prop1
{
set { field = value; }
}
}
/////////////////////////////////////////////////////
Error: None
Detail:
So the only way out is implement the Write only property as write only explicitly.
I hope this helps to understand the write only property behavior in reference to Abstract & Virtual.
Sunday, September 23, 2012
E-Book Collection
Check out the large collection of Free Microsoft eBooks for you, including: SharePoint, Visual Studio, Windows Phone, Windows 8, Office 365, Office 2010, SQL Server 2012, Azure, and more.
http://blogs.msdn.com/b/mssmallbiz/archive/2012/07/27/large-collection-of-free-microsoft-ebooks-for-you-including-sharepoint-visual-studio-windows-phone-windows-8-office-365-office-2010-sql-server-2012-azure-and-more.aspx
Saturday, June 16, 2012
Building Windows 8 Metro Style Application
The windows application development is keep evolving. The day from FoxPro, Visual FoxPro, Visual Basic, .Net WinForms, WPF.
Now it is big move for Windows 8. The decade old typical windows app style is replaced with metro style. The OS API are evolved, the world is more connected, the UI interfaces evolved, the devices are evolved. Windows OS is embracing major change in Windows 8.
The transition is trend change and requires completely different approach. Getting started with Windows 8 needs solid understanding. Here is the complete training available from Channel 9.
- Introduction to the Windows 8 platform and the Windows store
- Designing apps with Metro style principles and the Windows personality
- Building Metro style apps with XAML: What .NET developers need to know
- What HTML developers need to know about coding Windows 8 Metro style apps
- Win as One: How Contracts in Windows 8 Help You Build a Killer Metro App
- Bring Your Windows 8 Metro Style Apps to Life with Tiles and Notifications
- Building Windows 8 Metro style casual games using HTML 5
Wednesday, May 9, 2012
Run-time assembly creation
There are times where you may need to generate Assembly dynamically at run-time. The blog post shares some code for the same.
public CompilerResults Compile()
{
//Set the compiler options
var compilerOptions = new Dictionary<string, string>();
compilerOptions.Add("CompilerVersion", "v4.0");
CodeDomProvider compiler = new CSharpCodeProvider(compilerOptions);
CompilerParameters parameters = new CompilerParameters();
parameters.WarningLevel = 4;
parameters.TreatWarningsAsErrors = false;
parameters.GenerateExecutable = false;
parameters.GenerateInMemory = false;
parameters.OutputAssembly = GetFileName();
parameters.IncludeDebugInformation = false;
if (RoleEnvironment.IsAvailable)
parameters.TempFiles = new TempFileCollection(RoleEnvironment.GetLocalResource("CompilerTempFiles").RootPath, false);
string baseDir = Path.GetDirectoryName(
Assembly.GetExecutingAssembly().Location);
baseDir = baseDir.Substring(0,
baseDir.LastIndexOf(Path.DirectorySeparatorChar));
baseDir = baseDir.Substring(0,
baseDir.LastIndexOf(Path.DirectorySeparatorChar));
//Add required assembly references of your code
string assemblyName;
foreach (string assembly in GetReferences())
{
string suffix = assembly.EndsWith(".exe") ? "" : ".dll";
assemblyName = assembly;
if (!assembly.StartsWith("System"))
{
if (assembly.IndexOf(".dll") > -1)
{
assemblyName = FindAssembly(baseDir, assembly);
suffix = "";
}
parameters.ReferencedAssemblies.Add(assemblyName + suffix);
}
else
{
var assemblyPath = (from assm
in AppDomain.CurrentDomain.GetAssemblies()
where assm.FullName.IndexOf(assemblyName + ",") > -1
select assm).FirstOrDefault();
if (assemblyPath == null)
{
throw new Exception("Unable to locate assembly: "
+ assemblyName + suffix);
}
parameters.ReferencedAssemblies.Add(assemblyPath.Location);
}
}
//Get your dynamic code
string Code = GetCodeText();
CompilerResults results = compiler.CompileAssemblyFromSource(
parameters, Code);
return results;
}
With dynamic code you must have some known interface, so that you can create the dynamic object of given interface to invoke the code.
public IKnownInterface GetTableServiceContext()
{
string assemblyPath = GetFileName();
if (!File.Exists(assemblyPath))
{
throw new FileNotFoundException(assemblyPath + " not found");
}
System.Reflection.Assembly assem = AppDomain.CurrentDomain.Load(
File.ReadAllBytes(assemblyPath));
Type queryType = assem.GetType("DynamicClassName");
return Activator.CreateInstance(queryType) as IKnownInterface;
}
We should be avoiding dynamic code generation and look for solutions like dependency injection, MEF frameworks.
Wednesday, April 18, 2012
SSIS–DFT does not loads last row from flat file
Yesterday, I had an interesting issue. It has been reported me that an ETL always misses the last row from the flat file. No matter what is the row is it happens for every file that the last row is missing.
It is wired issue, I started check the ETL and created a new ETL with DFT pointing the same share file. I could able to get all the rows. It was happening only in that particular ETL.
I copied the DFT from the error ETL to my new ETL. The problem disappeared. I was wondering about the magic happening here. The DFT is same, data file is same but the last row is getting missed.
I started comparing the ETL config and connections. oh…at last I could able to figure out the issue. It was due the Text Qualifier setting which update on the Flat File Connection component. Make sure it set to None, if you don’t have any special handling.
Related MSDN discussion
Monday, April 16, 2012
Web API
Web API is the emerging trend in the Web programming.
The WiKi defines as “A web API (Application Programming Interface) is typically a defined set of HTTP request messages along with a definition of the structure of response messages, typically expressed in JSON or XML. While "web API" is sometimes considered a synonym for web service, the Web 2.0 applications typically have moved away from SOAP-based web services towards more direct REST-style communications.[1] Web APIs allow the combination of multiple services into new applications known as mashups”
Check out the PDC 10 talk on Building Web API which gives insight on how Microsoft approaches Web API.
Getting Started with ASP.NET Web API
Check out the blog to get started Tutorial
Friday, April 13, 2012
SQL Table Size
Many times you may want to check the size of set of tables in SQL server. There are multiple ways to achieve the same.
DECLARE @Unit CHAR(2)
DECLARE @SlicerSize FLOAT
SET @Unit = 'GB' --MB
CREATE TABLE #DataSize
(
RowId INT IDENTITY,
TableName SYSNAME,
DataRowCount BIGINT,
Reserved VARCHAR(20),
Data VARCHAR(20),
IndexSize VARCHAR(20),
Unused VARCHAR(20)
)
SELECT @SlicerSize = CASE WHEN @Unit = 'GB'
THEN 1024.0 / 1024.0
ELSE 1024.0
END
-- Add the table you want to check the size
INSERT #DataSize EXEC sp_executesql N'EXEC sp_spaceused [dbo.Emp]'
INSERT #DataSize EXEC sp_executesql N'EXEC sp_spaceused [dbo.Address]'
SELECT TableName,
DataRowCount / 1000 AS RowCountInKs ,
CONVERT(DECIMAL(10,2),CONVERT(INT,REPLACE(Reserved,' KB','')) / @SlicerSize) AS ReservedSpace ,
CONVERT(DECIMAL(10,2),CONVERT(INT,REPLACE(Data,' KB','')) / @SlicerSize) AS DataSize ,
CONVERT(DECIMAL(10,2),CONVERT(INT,REPLACE(IndexSize,' KB','')) / @SlicerSize) AS IndexSize,
@Unit AS Unit
FROM #DataSize
DROP TABLE #DataSize
Thursday, April 12, 2012
Encryption
Encryption is used to product the data. There are 2 types of encryption.
- Symmetric: The key used to encrypt and decrypt are same.
- Asymmetric
Symmetric Encryption
There 4 different algorithms we can use to encrypt data in C#
- DES
- TripleDES
- RC2
- Rijndeal
Asymmetric Encryption
- In Asymmetric encryption data is get signed using public key and decrypted using private key. for complete list and detail check MSDN Article
Tuesday, April 10, 2012
Securing you Azure Connection String
With windows Azure you have dependency on the Keys, like storage key, sql authentication. It is important to encrypt them and secure it. There is good article which details the steps to secure your connection strings.
Configuring specific section of web.config
- Creating Certificate
- Uploading Certificate to Azure portal
- Encrypting & updating web.config
- Config Provider
for Encrypting and Decrypting string using certificate refer http://msdn.microsoft.com/en-us/library/windowsazure/hh697511.aspx
Tuesday, February 28, 2012
C# by examples
I came across an excellent site which list all C# techniques and provides very simple examples on each topic. It is good recommandation for any who starts learning C#.
http://www.java2s.com/Tutorial/CSharp/CatalogCSharp.htm
Friday, February 3, 2012
Windows Azure Resources
- Service Bus Demo -
- http://www.brianloesgen.com/blog/2012/1/23/new-azure-servicebus-demo-available.html
- http://www.youtube.com/watch?v=xKHl87_BFT0&feature=youtu.be
- http://serviceBusEventDemo.codeplex.com
- Email service
- Browser based cloud app development
- SQL Azure Import/Export Service Now in Production
- Transient Fault Handling Application Block
Wednesday, February 1, 2012
Windows Phone 7 Resources
- Windows Phone 7 sampleshttp://www.jeffblankenburg.com/2010/09/30/31-days-of-windows-phone-7
- Mango samplehttp://jeffblankenburg.com/31daysofmango
- Silverlight toolkit http://silverlight.codeplex.com
- Localization tool http://patrickgetzmann.wordpress.com/wp7-localize
- Optimizing and testing WP7
http://research.microsoft.com/apps/video/default.aspx?id=156138 - UX: http://blogs.msdn.com/b/belux/archive/2011/12/01/web-amp-phone-ux-event-recordings-slides-and-content-now-available.aspx
- Channel 9 - Inside WP7: http://channel9.msdn.com/Shows/Inside+Windows+Phone
- Youtube Video: http://www.youtube.com/user/windowsphone?feature=watch
- Training: http://www.pitorque.de/MisterGoodcat/post/Free-Windows-Phone-Training.aspx
- Must have dev tools: http://www.diaryofaninja.com/blog/2012/01/23/8-musthave-tools-for-windows-phone-7-development
- MetroSky: http://code.msdn.microsoft.com/MetroSky-A-Complete-4250b80f
Saturday, January 21, 2012
Metro Design
Principles
- Light & simple: No glassy buttons are rich graphics. Simple flat graphics
- Typography: Beauty is given importance, Have specific type (ex Segoe) use at various weightages to have textual hierarchy
- Motion: The lively of the application is given importance, little animation added for every user interface and page transitions
- Content, not chrome: Important is for the content not for controls, so unnecessary controls are removed, so no more scroll bar for a list, a list it self can be scrollable.
- Honesty: It is unique and new style
Principles talks about abstract concepts language takes a shape.
- Navigation: Pivot & Panaroma
- Motion: Animations
- Iconography: Flat icon set
- Images & Photos
- Themes & Personalization
- Touch Gestures & Targets
- UI controls: Application Bar, Application Bar Menu
- Hardware
- Services
- Marketplace and Branding
Friday, January 6, 2012
SQL Server 2008 High Availability
High availability configuration is a tricky area for me, I feel Operation team will take care on them!! and never ventured to understand in depth. But today I came across simple video on configuring high availability options in a simple way. It is simple and clear.
Grouping set in SQL Server 2008
Sample Table
|
|
||||||||||||||||||||||||||||||||||||
SELECT EmpId, Yr, SUM(Sales) AS Sales
FROM Sales
GROUP BY EmpId, Yr WITH ROLLUP
OR
SELECT EmpId, Yr, SUM(Sales) AS Sales
FROM Sales
GROUP BY ROLLUP(EmpId, Yr)
|
|
||||||||||||||||||||||||||||||||||||
SELECT EmpId, Yr, SUM(Sales) AS Sales
FROM Sales
GROUP BY EmpId, Yr WITH CUBE
OR
SELECT EmpId, Yr, SUM(Sales) AS Sales
FROM Sales
GROUP BY CUBE(EmpId, Yr)
|
|
||||||||||||||||||||||||||||||||||||
SELECT EmpId, Yr, SUM(Sales) AS Sales
FROM Sales
GROUP BY GROUPING SETS((EmpId, Yr), (EmpId), ())
|
|
||||||||||||||||||||||||||||||||||||
SELECT EmpId, Yr, SUM(Sales) AS Sales
FROM Sales
GROUP BY GROUPING SETS((EmpId, Yr), (EmpId))
|
|
||||||||||||||||||||||||||||||||||||
SELECT EmpId, Yr, SUM(Sales) AS Sales
FROM Sales
GROUP BY GROUPING SETS((EmpId, Yr), (EmpId))
|
|
||||||||||||||||||||||||||||||||||||
SELECT EmpId, Yr, SUM(Sales) AS Sales
FROM Sales
GROUP BY GROUPING SETS((EmpId), (Yr))
|
|
||||||||||||||||||||||||||||||||||||
SELECT EmpId, Yr, SUM(Sales) AS Sales
FROM Sales
GROUP BY GROUPING SETS((EmpId, Yr))
|
|
||||||||||||||||||||||||||||||||||||
SELECT EmpId, Yr, SUM(Sales) AS Sales
FROM Sales
GROUP BY GROUPING SETS((EmpId, Yr), (EmpId) )
OR
SELECT EmpId, Yr, SUM(Sales) AS Sales
FROM Sales
GROUP BY GROUPING SETS((EmpId), (Yr, EmpId))
|
|
Teams PowerShell
The PowerShell helps to get quick meta data around Teams. Install-Module -Name MicrosoftTeams Connect-MicrosoftTeams Get-TeamAllChannel...
-
I was trying to install SharePoint 2013, the setup was complaining about a pending system restart. Even after multiple restart / Shutdown. ...
-
Recently a new learner of C# asked me a question on C# Virtual & Abstract properties. It turned out to a deep dive. Detail follows. D...
-
source 1. Microsoft .NET Framework interview questions .NET 2. What is .NET Framework? 3. Is .NET a runtime service or a developm...