Theyre similar enough to be compared
They are both MOBAs, so in that sense, yes. However, their play-styles differ greatly. It would be like comparing a Monster Truck to a Ferrari because they are motorized vehicles.
DotA 2 is all about consequences. If you die, not only does the enemy get bonus gold, but you also lose gold. You can't just teleport back to base whenever you want, you have to buy a teleport scroll that also takes up an item slot. People will sell a 3k item late game just to make room for one of these scrolls.
League of Legends isn't so harsh. If you die, the enemy gains gold, but it's not as big of a loss. You are also able to roam around the map and extend further because you are always able to teleport back to your base for free whenever you want.
While both games are item-centric, DotA 2 puts a greater emphasis on this aspect by having you risk your gold by staying in lane. This adds an additional element to the game by making you figure out what time is good for you to leave (and possibly give up control) of your lane to purchase items. The longer you stay in lane, the greater the chance that you'll get ganked, meaning that all the extra farming you did actually benefits the enemy instead of you.
The difference in these mechanics put a giant emphasis on gold and, in turn, lane control in DotA 2. Lane control is found in both games and revolves around a few things; not overextending, ganking, pushing towers, and denying.
If you push your lane too hard, you leave yourself open to getting ganked from behind, meaning you're trapped between two enemy champions. The biggest difference between the two games is that you aren't punished quite as hard in LoL. If you think someone might be coming to gank you, you can hid in the brush (something DotA 2 doesn't have) and then teleport back to base. In DotA 2, if you're caught overextending, you either have to hope you can out run or dodge the gank, or use your hard earned gold to buy a teleport scroll.
Ganking means that you are the one to spot when an enemy over extends and use that window of opportunity. Again, LoL is less punishing in this area. If you set up a gank and it fails (assuming nobody at all died), you can simply get back into your lane and pick up where you left off with little to no loss. In DotA 2, if your gank fails, you just wasted a lot of farming time and possibly control of your lane.
Pushing towers means you are able to safely push your minions to their tower and deal damage to it, ultimately destroying it, without allowing them to do the same to you. Because you have to extend (and possibly overextend) to push the towers, it presents similar risks to overextending, therefore meaning that LoL is a lot less punishing in this respect.
Denying means that you are able to prevent enemy champions from gaining experience and gold while in lane. This is the biggest of the differences between the two games and effects gameplay the most. In LoL, denying means that you are able to harass the enemy to keep them from last-hitting (which would get them additional gold though they still gain the normal amount of exp) or by pushing the minion wave to the tower while they're out of lane (this results in the deaths of your minions without the enemy champion getting gold OR experience). In DotA 2, you are able to attack your own minions, meaning that you can last-hit them to stop the enemy champion from gaining experience or gold, even though they are in lane. This is a major difference because you not only have to watch to see when enemy minions are low on health, but when your own are also, so that you can maximize your control of the lane. By killing your own minions in this way, you allow the enemy to get closer to your own tower, creating ganking opportunities for your teammates.
These are fundamental differences in the core of each game, resulting in completely different play-styles. LoL focuses more on the aspect of "team fights", resulting in fast gameplay with multiple power shifts during the course of a single match. Careful timing, positioning and targeting can allow an underdog team the time to push entire lanes, shifting the balance of the game completely. DotA 2 focus more on the laning aspect of the game, punishing those who die by essentially giving hard earned gold to the enemy team. This results in a much slower, "snowball" type game that will generally only have 1 or 2 shifts in power during the game, tilting the losers into a difficult position to win from.
Final thing, I myself don't play DotA 2, so it might have some inaccuracies in regards to that specific game. However, I got all my information from my brother who does play (and prefers) DotA 2. Keep in mind that the reason he prefers it is simply because he enjoys that style of slower, building gameplay and considers both games to be good in their own rights. Here is a quote by him explaining the concept of denying (he does a better job than I do):
Oh and so like a major difference between LoL and DotA is the punishment. Im not gunna say anything about gameplay or style here. DotA will punish you for everything you make a mistake on. When you die not only do the enemy get gold but you lose gold. You can't just b back to base, you have to purchase the 135 tp scroll which also takes up an item slot. Infact some people will sell 3000 gold items just to make room for a tp scroll late game. But as i was saying, you cant just tp when ever you want cause your losing gold.
Also its easy to lose a lane and if your not on top of it you can be punished for that. Denying creeps makes it unable for the enemy team to get the last hit, but not only that it denys exp. Plus it pushes your lane back to your tower. making laning safer and ganks easier.
Denying works by allowing you to target your own creeps if they have 50% or lower health. You cant right click your own either, you have to a-click the individual unit to do so. Towers are the same but can only be denyed if they are under 180 hp. when you kill a tower normally the whole team gets 200 gold, and if some one last hits i think thats person gets an added 200 making 400 gold. If you deny it only gives the enemy 100 gold each. Thats a big difference cause instead of giveing the enemy 1000 or more gold your reduce it to only 500 so its pretty important to deny.