This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Migration(1)] | |
// Može se postaviti i timestamp umijesto rednog broja | |
// [Migration(201201311705)] | |
public class CreateUserTable : Migration | |
{ | |
public override void Up() | |
{ | |
Create.Table("User") | |
.WithColumn("Id").AsInt32().NotNullable().PrimaryKey().Identity(); | |
.WithColumn("Username").AsString(50).NotNullable() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Migration(2)] | |
// Može se postaviti i timestamp umijesto rednog broja | |
// [Migration(201201311710)] | |
public class CreateUserTable : Migration | |
{ | |
public override void Up() | |
{ | |
Create.ForeignKey("fk_tag_user") | |
.FromTable("Tag").ForeignColumn("CreatorId") | |
.ToTable("User").PrimaryColumn("Id") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@{ | |
// sve unutar ovog bloka je c#, a ostalo je HTML | |
var db = Database.Open("ImeBaze"); | |
var news = db.Query("SELECT * FROM NewsItems ORDER BY NewsDate DESC"); | |
db.Execute("INSERT INTO NewsItems (Title) VALUES (@0)", "Naslov"); | |
} | |
<html> | |
<body> | |
<table> | |
@foreach(var newsItem in news) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Product | |
{ | |
public int ProductId { get; set; } | |
public int Name { get; set; } | |
public decimal Price { get; set; } | |
public virtual Category Category { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public partial class Init : DbMigration | |
{ | |
public override void Up() | |
{ | |
CreateTable( | |
"dbo.Products", | |
c => new | |
{ | |
ProductId = c.Int(nullable: false, identity: true), | |
Name = c.Int(nullable: false), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Extensions | |
{ | |
public static MvcHtmlString WriteIfError<M, P>(this HtmlHelper<M> htmlHelper, Expression<Func<M, P>> expression, string value) | |
{ | |
string expressionText = ExpressionHelper.GetExpressionText(expression); | |
string modelName = htmlHelper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(expressionText); | |
if (!htmlHelper.ViewData.ModelState.ContainsKey(modelName)) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* data context */ | |
class MyDataContext : DbContext, IDataContext | |
{ | |
public IDbSet<BlogPost> BlogPosts { get; set; } | |
} | |
interface IDataContext | |
{ | |
IDbSet<BlogPost> BlogPosts { get; set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-Process WebDev.WebServer40 | Stop-Process |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
update rp | |
set rp.TitleDuplicateCount = rj.tcount | |
from ReportPages rp | |
inner join | |
( | |
select count(rp2.TitleHash) as tcount, rp2.TitleHash | |
from ReportPages rp2 | |
where rp2.ProjectId = {0} and PageType = 1 and HasTitle = 1 | |
group by rp2.TitleHash | |
having COUNT(rp2.titleHash) > 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HomeController : Controller | |
{ | |
public ActionResult Index() | |
{ | |
var first = new FirstModel(); | |
var second = new SecondModel(); | |
return View(Tuple.Create(first,second)); | |
} | |
} |
OlderNewer