Software development tutorials and demos lasting no more than 60 seconds.
No in-depth explanations, no off-topic rants, and no slides. One small topic per video - only code, console, config, and client.
All videos come with a corresponding blog entry, and all code is available on GitHub.
if(!Array.prototype.map){
Array.prototype.map =function(callback/*, thisArg*/){var T, A, k;if(this==null){thrownew TypeError('this is null or not defined');}var O = Object(this);var len = O.length>>>0;if(typeof callback !=='function'){thrownew TypeError(callback +' is not a function');}if(arguments.length>1){
T = arguments[1];}
A =new Array(len);
k =0;while(k < len){var kValue, mappedValue;if(k in O){
kValue = O[k];
mappedValue = callback.call(T, kValue, k, O);
A[k]= mappedValue;}
k++;}return A;};}
If you need a left join in Entity Framework, you have a couple options. First, if you’re using a real foreign key that just happens to be nullable, then you can use the regular navigation properties. But if you’re doing a left join manually, or with other factors, then you need to do things just a little differently: Suppose we have the following database: create table dbo . Foods ( FoodID int not null identity primary key , FoodName varchar ( 100 ) not null ) ; go insert dbo . Foods ( FoodName ) values ( 'Pizza' ) , ( 'Chicken' ) , ( 'Potatoes' ) , ( 'Broccoli' ) ; go create table dbo . People ( PersonID int not null identity primary key , FirstName varchar ( 100 ) not null , FavoriteFoodID int null , constraint FK_Person_FavoriteFoodID foreign key ( FavoriteFoodID ) references dbo . Foods ( FoodID ) ) ; go insert dbo . People ( FirstName , FavoriteFoodID ) values ( 'John' , 1 ) , ...
If you have text on the server that may have line breaks, you may have gone through a series of steps to get it to display properly. First, if you weren't really thinking about it, you just dump the output to the screen. ASP.NET and others HTML encode it, so you generally don't have to worry about any kind of script injection. But the line breaks aren't handled properly. < div id = output > @message </ div > *@ Next thing to try, replacing line breaks with a BR tag. Of course, since it's encoded, the HTML shows up as text, and that's no good. < div id = output > @( message . Replace("\r\n", " < br > ").Replace("\n", " < br > ").Replace("\r", " < br > ") ) </ div > Ok, now you need to use Html.Raw, but you can't do it on the whole string because that will put the dangerous raw text into the page. So you have to encode the message, after replacin...
Comments
Post a Comment