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
private IEnumerable<string> GetItems() | |
{ | |
var result = new List<string>(); | |
result.Add("Test1"); | |
result.Add("Test2"); | |
result.Add("Test3"); | |
return result; | |
} |
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
private IEnumerable<string> GetItems() | |
{ | |
yield return "Test1"; | |
yield return "Test2"; | |
yield return "Test3"; | |
} |
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
<asp:DropDownList ID="ddlItems" runat="server"> | |
<asp:ListItem Text="<--Select Item-->" Value=""></asp:ListItem> | |
<asp:ListItem Text="Item 1" Value="1"></asp:ListItem> | |
<asp:ListItem Text="Item 2" Value="2"></asp:ListItem> | |
<asp:ListItem Text="Item 3" Value="3"></asp:ListItem> | |
</asp:DropDownList> | |
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="ddlItems" runat="server" ErrorMessage="Please select an item" Text="Please select an item"></asp:RequiredFieldValidator> |
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 Person | |
{ | |
public string FirstName { get; set; } | |
public string LastName { get; set; } | |
public int Age { 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 class Person | |
{ | |
private string _firstName; | |
private string _lastName; | |
private int _age; | |
public string FirstName | |
{ | |
get | |
{ |
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 ActionResult Index(int accountId) | |
{ | |
var account = _accountContext.Accounts.SingleOrDefault(acct => acct.ID == accountId); | |
var history = _financialContext.AccountHistory.Where(acct => acct.ID == accountId); | |
var paymentInfo = _paymentProcessor.GetPaymentProfile(accountId); | |
var sources = new Tuple<Account, IEnumerable<Transaction>, PaymentProfile>(account, history, paymentInfo); | |
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 AccountSummaryViewModel | |
{ | |
//Comes from account | |
public int AccountID { get; set; } | |
public string AccountName { get; set; } | |
public DateTime ExpirationDate { get; set; } | |
//Comes from paymentInfo | |
public string PaymentMethod { 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
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var x = Operations[Operation.NotEquals]; | |
Console.WriteLine(x); | |
Console.ReadKey(); | |
} | |
enum Operation |
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
var posts = context.Posts.ToArray(); | |
var model = (from post in posts | |
select new PostsViewModel | |
{ | |
Title = post.Title, | |
Url = post.Url, | |
AuthorName = post.Author.Name, | |
AuthorTwitterHandle = post.Author.TwitterHandle | |
}).ToArray(); |
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
//Uses string notation - lots of typos! | |
//var posts = context.Posts | |
// .Include("Author") | |
// .ToArray(); | |
//Uses lambda notation - Intellisense and easy refactoring = love | |
//Note: include System.Data.Entity to use. | |
var posts = context.Posts | |
.Include(p => p.Author) | |
.ToArray(); |
OlderNewer