Live data from Hacker News

Open Source .NET libraries that make your life easier

thomasvm.github.io

51–60 of 116 posts

Re: Open Source .NET libraries that make your life easier

#51
post #36
post #22

Earlier quoted context omitted.

I've just rolled out a service using TopShelf having not used it previously. It really does simplify things. The best bit for me is being able to just hit F5 and having the thing run as a console application. No need to manually attach to processes for debugging.

This technique lets you debug your service as if it were a console app - just pass in -a on the command line. In your Main method: if (args.Length > 0 && args[0] == "-a") { // Running as an application MyService ms = new MyService(); ms.DoStart(); Console.WriteLine("Press Enter to Stop"); Console.ReadLine(); ms.DoStop(); } else { // Running as a service ServiceBase[] servicesToRun = { new MyService() }; ServiceBase.R…

I normally use this (simple) technique: http://stackoverflow.com/a/126016

Re: Open Source .NET libraries that make your life easier

#52
post #46

I'd like to add one that's great for turning the web into a query-able database: HtmlAgilityPack. HtmlAgilityPack + Linq is amazing.

For working with HTML (parsing, extracting), I'd like to add HtmlTypeProvider from F# Data as one of the options. :)

Re: Open Source .NET libraries that make your life easier

#54

Earlier quoted context omitted.

Even then, for query building I found EF (or any LINQ provider for SQL) to be easier solution than string concatenation. Well, at least for relatively simple queries with pagination and stuff. For filters, Dynamic.Linq would be helpful here. On the other side, if you need to work extensively with stored procedures or you have complicated or custom SQL to run, Dapper (or Insight.Database - https://github.com/jonwagner…

It's true. What I really would like is a micro-orm like Dapper with support for using LINQ to dynamically build queries. But I suppose this is essentially EF with AsNoTracking, which I have yet to play around with and test performance wise.

AsNoTracking makes the materialization indeed faster, but EF always has a cost associated with it, both for initial use (set up of the context etc, which is noticeable) as well as every other query after that (expression tree parsing etc, not as noticeable especially for recurring queries).

I hope it's one of the pain points they will address and solve during their rewrite to EF7 at one point.

That being said, my opinion is that unless you have really strict performance and/or latency requirements, EF should be good enough. At least for simpler queries and in 'longer-running' applications :)

Re: Open Source .NET libraries that make your life easier

#55
With .NET going open source, I'd like to see what is out there for web services. Are there any linux-compatible .NET web servers/routers that I can use that have a similar feature set and performance to the Spray/Scala stack? C# or F#, but preferably F#. I've tried a couple (suave, nancy), but some simple benchmarks showed they were about half as scalable as spray.

Re: Open Source .NET libraries that make your life easier

#56
post #4

To add to the author's list: * I seem to install Json.net in every .NET project I create (json serializer - thanks James Newton-King!) * NLog for logging. It's fantastic. * Dapper is also excellent (Micro ORM) (and anything written by Marc Gravell is generally top-notch - see protobuf-net, miniprofiler, StackExchange.Redis) * Automapper, to avoid writing boilerplate code to convert between similarly shaped types (E.G…

Dapper is a really awesome library when you want to write complex queries (full of table hints, output clauses, merges and other advanced stuff), but don't want to write enormous amount of code for adding parameters and reading result sets.

Personally, I think it's great even for crud...It's an order of magnitude faster than things like EF/LINQ2SQL

Re: Open Source .NET libraries that make your life easier

#57
post #16

Surprised no one has mentioned Nancy: https://github.com/NancyFx/Nancy I can't imagine building APIs without it now.

I find NancyFX really interesting, but I can't really see a reason to stray away from Web API2 besides Mono support. Any specific reasons you prefer Nancy?

It's nice to serve webapi's and serverside pages from the same class. I like the content negotiation in Nancy. Also the built-in testing features are nice, it is easy to test views too.

Re: Open Source .NET libraries that make your life easier

#58
One of my recent favorite libraries lately is DynamicData [1] which is Rx for collections. It allows you to use LINQ operators to create lots of different collections from a single "observable cache". An example from the github page:

    var list = new ObservableCollectionExtended();
    var myoperation = somedynamicdatasource
                        .Filter(trade=>trade.Status == TradeStatus.Live) 
                        .Transform(trade => new TradeProxy(trade))
                        .Sort(SortExpressionComparer.Descending(t => t.Timestamp))
                        .ObserveOnDispatcher()
                        .Bind(list) 
                        .DisposeMany()
                        .Subscribe()
This takes the collection at somedynamicdatasource, transforms the contents to TradeProxy objects, sorts it, and binds it to list. Any time that an object is added or removed in somedynamicdatasource, list will be updated to match. This library has over 50 operators including dynamic filters (changing the filter causes the bound collection to be reevaluated), boolean operators (only update the resulting collection if the object is in both source collections or only one), etc.

[1] https://github.com/RolandPheasant/DynamicData

Re: Open Source .NET libraries that make your life easier

#60
post #56

Earlier quoted context omitted.

Dapper is a really awesome library when you want to write complex queries (full of table hints, output clauses, merges and other advanced stuff), but don't want to write enormous amount of code for adding parameters and reading result sets.

Personally, I think it's great even for crud...It's an order of magnitude faster than things like EF/LINQ2SQL

Agreed. And really it's pretty simple to get it working and start using it even for straight crud - much easier than EF or other heavy ORMs, I think.
Post reply on HN