|
|
Saturday, December 25, 2010 |
LINQ to Entities and constructors with parameters
Posted: 3:42:00 PM
|
Merry Christmas! You can tell you love something if you do it while on vacation and holidays, so let's jump right into it.
I recently converted the data access layer of Six Minutes To Release to LINQ to Entities. Aside from a bit of syntactical change, the conversion was painless. That is, until I got into the runtime:
Only parameterless constructors and initializers are supported in LINQ to Entities.
Fair enough. What I like to do is to create a class that I can quickly dump the results of a LINQ to SQL query into. Typically I'll use this for ListViews. For example:
ListView1.DataSource = (From t In db.table Select New DataClass(t, t.otherTable.Value, t.otherTable.Value2))
The problem is not that LINQ can't do this, it's specifically LINQ to Entities. So what you need to do instead is a 2-step process. First, take the data out of LINQ to Entities. Then, deal with the data in LINQ. How do you do this? By using .ToList() to process the query in LINQ to Entities and using a second query to get it into the class.
Dim query = (From t in db.table Select New With {.Table = t, .Value = t.otherTable.Value, .Value2 = t.otherTable.Value2})
ListView1.DataSource = (From q in query Select New DataClass(q.Table, q.Value, q.Value2))
Ideally, I'd like to get all this stuff out of ASP.Net and use jQuery templates instead, but that would be more legacy code converting than I have time for these days. So for now, this will be the solution I use.Labels: Coding, LINQ to Entities, VB.NET
|
Wednesday, December 08, 2010 |
Cyberwars
Posted: 1:23:00 PM
|
If you haven't heard about the whole WikiLeaks ordeal by now, you've probably been hiding under a rock. The short of it is that WikiLeaks has been publishing classified government documents on the Internet. There are arguments as to whether or not doing so is considered treason. This article does not address this topic, but it is the argument itself that is the heart of this post.
A bit of a background. I use EveryDNS to host my DNS needs. This includes domain name resolution for roncli.com, Outpost Music, Six Minutes To Release, and even this blog. It is an excellent free service, and I highly recommend it to anyone that needs DNS services.
EveryDNS, however, is between the proverbial rock and hard place.
You see, EveryDNS also hosted the DNS entries for many of the WikiLeaks websites. I say "hosted", because they discontinued hosting them on December 2nd.
EveryDNS.net provided domain name system (DNS) services to the wikileaks.org domain name until 10PM EST, December 2, 2010, when such services were terminated. As with other users of the EveryDNS.net network, this service was provided for free. The termination of services was effected pursuant to, and in accordance with, the EveryDNS.net Acceptable Use Policy.
The assumption made here, of course, is that EveryDNS believes that WikiLeaks is wrong, and that taking it offline is the best course of action. Well, some people support WikiLeaks, including Operation Payback. This is group of people who want to payback those who do what they perceive as wrong on the Internet. And, apparently, they have deemed WikiLeaks to be wrong.
But, as is often in life, assumptions may not always be the truth:
More specifically, the services were terminated for violation of the provision which states that "Member shall not interfere with another Member's use and enjoyment of the Service or another entity's use and enjoyment of similar services." The interference at issues arises from the fact that wikileaks.org has become the target of multiple distributed denial of service (DDOS) attacks. These attacks have, and future attacks would, threaten the stability of the EveryDNS.net infrastructure, which enables access to almost 500,000 other websites.
And the cyberwar begins. EveryDNS is afraid of being DDOS'd due to them hosting the DNS to WikiLeaks' websites. EveryDNS shuts WikiLeaks' DNS down to protect themeselves. Operation Payback responds by DDOSing EveryDNS.
Is there any way EveryDNS can win?
Granted, I'm assuming that the story EveryDNS gives us is true, and we all know where assumptions lead us.Labels: Editorials, EveryDNS, Operation Payback, WikiLeaks
|
|