Linq to SQL Combine two columns to make a readonly custom column

var rqSaleRepId = from m in db.RequestSaleReps select new { m.RequestSaleRepId, @RepNoWithName=m.SaleRepNo + ” – ” + m.Name};
ViewData["RequestSaleRepID"] = new SelectList(rqSaleRepId, “RequestSaleRepId”, “RepNoWithName”, editView.RequestSaleRepId);

<%= Html.DropDownList("RequestSaleRepId", (IEnumerable)ViewData["RequestSaleRepID"])%>

Read More

Insert, Update, and Delete Operations – LINQ to SQL

Northwnd db = new Northwnd(@”c:\Northwnd.mdf”);

// Query for a specific customer.
var cust =
(from c in db.Customers
where c.CustomerID == “ALFKI”
select c).First();

// Change the name of the contact.
cust.ContactName = “New Contact”;

// Create and add a new Order to the Orders collection.
Order ord = new Order { OrderDate = DateTime.Now };

// Delete an existing Order.
Order ord0 = cust.Orders[0];

// Removing it from the table also removes it from the Customer’s list.

// Ask the DataContext to save all the changes.

Read More
TOP MVC Strongly Typed Html Helpers

Read More

Switch to our mobile site