On Sun, Oct 10, 2010 at 10:19 AM, Joe Pluta <joepluta@xxxxxxxxxxxxxxxxx> wrote:
On 10/10/2010 4:28 AM, Steve Richter wrote:
big advantage to using C# is that it is pretty much identical to javascript.
Not from my standpoint. C# is different from JavaScript on the most
fundamental level: it's a strongly typed language. From that
standpoint, Java is closer to JavaScript than C# (there's no goto in
JavaScript!).
what I am trying to say is the syntax is very similar. If a programmer
working for you prefers to use VB, you have to ask what are they going
to do when they have to write some jquery for the browser.
Here is a javascript function. Other than the function keyword, the
absence of a return type and the jquery $, it is C# code:
function master_ModeToIndexAction( )
{
var s3 = $('input[name=mode]:radio:checked').val();
var action = null;
if (s3 == 'Inventory')
action = 'InventoryIndex';
else if (s3 == 'Amazon')
action = 'AmazonIndex';
else if (s3 == 'Request')
action = 'RequestIndex';
else if (s3 == 'StockItem')
action = 'StockItemIndex';
else
action = 'BookIndex' ;
return action ;
}
Microsoft still holds the advantage in tools (to some degree) but Java
blows it away in reach.
I would like to know if any language or framework has the equivalent
of LINQ. Because of LINQ, .NET programmers no longer write SQL.
The following LINQ does the following:
- selects some rows from a database table
- groups the selected rows by a few keys
- joins from the group to a master file
- outputs the summary rows with the grouping keys, summary data and
some joined to master file data
- sorts that output
- builds a generically types list from the sorted output.
all of that selecting, sorting, grouping and joining can be done to
both database tables and any type of collection in memory.
the linq expression can also be serialized and transmitted over the
wire. So silverlight code running in the browser or on a windows 7
phone can build a linq expression, send it up to the server, have it
run on the server and receive the output back as a serialized xml
stream.
IQueryable<MerchantOfferSummary> itemOffers =
from c in Context.ItemOffers
where c.Asin == Asin.ToString()
group c by new {
c.Asin, c.MerchantId, c.CondLevel }
into g
join d in Context.MerchantMasters
on g.Key.MerchantId equals d.MerchantId
into j
from jo in j.DefaultIfEmpty()
select new MerchantOfferSummary
{
Asin = g.Key.Asin,
Nickname = jo == null ? "" : jo.Nickname,
MerchantId = g.Key.MerchantId,
Price = g.Min(x => x.Price),
AvailCount = g.Count(),
CondLevel = g.Key.CondLevel
};
return itemOffers.OrderBy(a => a.CondLevel)
.ThenBy(a => a.Price)
.ToList( ) ;
As an Amazon Associate we earn from qualifying purchases.