4 Dec 2013
Use transforms with any XML file in Visual Studio, not just web.config
Yesterday I discovered a handy little Visual Studio extension called, for some reason, SlowCheetah. Once installed you can right-click any XML file (usually you'll use this for config files) and get an 'Add Transform' option.
This allows you to use the XML transform notation so that published sites will pick up the correct settings based on the configuration used. It also means you won't be publishing files containing settings for other environments.
Nice!
17 Apr 2013
Responsive design infographic
I just stumbled across this great infographic containing 10 top tips for building responsive layouts. Great place to start.
28 Mar 2013
General programming rules #1
Don't use boolean method parameters.
Why? Because it makes your code unreadable and inextensible.
e.g. render(true) is meaningless but render(PageMode.Readonly) is semantic and unambiguous.
26 Mar 2013
Post an array in integers using Jquery & Ajax to MVC controller action
Mvc Action
public JsonResult Receive(int[] ages) { return Json(string.Format("ages {0} received", String.Join(",",ages))); }
Jquery Code
$(function() { $("#PostArray").click(function() { var arr = new Array(); arr.push(1); arr.push(21); arr.push(23); $.ajax({ url: '/Home/Receive', type: 'POST', contentType: 'application/json', dataType: 'json', data: JSON.stringify({ages: arr }), success: function(data) { alert(data); } }); }); });Download Example
List of ASP.NET Web API and HttpClient Samples
I just came across this massive list of web API code samples which is well worth a gander if you're looking at API development. And let's face it, in this new mobile age no developer can really be without this knowledge.
25 Mar 2013
Entity Framework 5 Many to Many relationship setup
Sample Solution Download Link
How to setup entity framework objects for many to many relationship.
I had a problem trying to get this to work but after I managed to get it working
I decided to post the solution here with a hope that it will help someone someday.
To begin.
1. Download the solution (it is a vs-2012 solution) & unzip accordingly
2. Create a database called (EdkSamples)
3. Create a login (user: developer, password: letmein$123)
4. Create database tables using the scripts
Edikgale.Samples.Data\Database Setup\DatabaseCreate.sql
5. Initialise the database data with the script in folder
Edikgale.Samples.Data\Database Setup\DataSetup.sql
6. To see how this works simply run the test in
EdwardDikgale\Edikgale.Samples.Data.Tests\EdikgaleEfContextTest.cs
Note
1. The test project uses a connection string defined in App.config which
you may wish to adapt accordingly.
2. The linking table is not modelled as a poco object because there is no need to unless
you happen to have some extra properties on it.
if you have any problems feel free to email me: edward.dikgale@gmail.com
I hope this helps you in some way
Ed
posted by: Edward Dikgale
How to setup entity framework objects for many to many relationship.
I had a problem trying to get this to work but after I managed to get it working
I decided to post the solution here with a hope that it will help someone someday.
To begin.
1. Download the solution (it is a vs-2012 solution) & unzip accordingly
2. Create a database called (EdkSamples)
3. Create a login (user: developer, password: letmein$123)
4. Create database tables using the scripts
Edikgale.Samples.Data\Database Setup\DatabaseCreate.sql
5. Initialise the database data with the script in folder
Edikgale.Samples.Data\Database Setup\DataSetup.sql
6. To see how this works simply run the test in
EdwardDikgale\Edikgale.Samples.Data.Tests\EdikgaleEfContextTest.cs
Note
1. The test project uses a connection string defined in App.config which
you may wish to adapt accordingly.
2. The linking table is not modelled as a poco object because there is no need to unless
you happen to have some extra properties on it.
if you have any problems feel free to email me: edward.dikgale@gmail.com
I hope this helps you in some way
Ed
posted by: Edward Dikgale
15 Mar 2013
100 Cool jQuery Plugins
Here's a great resource - 100 cool (and, in some cases, super-cool) jQuery plugins
13 Mar 2013
Some useful SQL statements
Here are a couple of SQL statements I seem to use on a regular basis.
-
Find all objects that contain specific text:
SELECT DISTINCT b.name + '.' + a.[name] FROM sys.objects a INNER JOIN sys.schemas b ON a.schema_id = b.schema_id INNER JOIN syscomments c ON a.object_id = c.id WHERE c.[text] LIKE '%CPRS%' -- AND a.[type] = 'P' -- stored procedure -- AND a.[type] = 'V' -- view -- AND a.[type] = 'FN' -- function etc.
-
Find all foreign keys for a specific table column:
SELECT f.name AS ForeignKey, OBJECT_NAME(f.parent_object_id) AS TableName, COL_NAME(fc.parent_object_id, fc.parent_column_id) AS ColumnName, OBJECT_NAME (f.referenced_object_id) AS ReferenceTableName, COL_NAME(fc.referenced_object_id, fc.referenced_column_id) AS ReferenceColumnName, COL_NAME(fc.parent_object_id, fc.parent_column_id) FROM sys.foreign_keys AS f INNER JOIN sys.foreign_key_columns AS fc ON f.OBJECT_ID = fc.constraint_object_id WHERE OBJECT_NAME (f.referenced_object_id) = '[TABLE_NAME]' AND COL_NAME(fc.parent_object_id, fc.parent_column_id) = '[COLUMN_NAME]'
12 Mar 2013
A few Twitter Bootstrap resources
Twitter Bootstrap is my best friend. Here are a few resources:
- Full overview of Bootstrap components
- The Big Badass List of Useful Bootstrap Resourcse
- Bootsnipp - gallery of HTML snippets for Bootstrap
If you have more to add to this list let me know.
27 Feb 2013
Code syntax highlighting in Blogger
I've added syntax highlighting to this blog's template. Here's an example:
// Comment public class Testing { public Testing() { } public void Method() { /* Another Comment on multiple lines */ int x = 9; } }
Subscribe to:
Posts (Atom)