Ok,
I was eagerly awaiting the release of subsonic 3.0 to use as my low-level data layer, and now its out. I'm currently using the ActiveRecord templates (having tried both the repository and advanced templates) and I have one HUGE request and a few questions:
Request: Other than bug fixes, Rob please spend the time to provide documentation. I don't mean 5 examples, I mean API complete documentation. Here's why:
I'm testing subsonic by writing ASP.NET MembershipProvider and RoleProvider classes and simple questions continually slow me up using subsonic:
Q. Assuming I have a class 'User' and I update/save/delete a record using
user.Save();
I need information on how to get success/failure? Do I look for an exception on failure or can I get a count of 'affected' records (old school?)
Q. If I get an exception, which exception(s) can I expect?
I'll have more issues, but I really believe a good functional API documentation would solve the problem.
If the answer is 'read the source code', then I'm sure you're going to chase quite a few developers away from subsonic. I really want to use the library, but the point is "use" the library, not reverse engineer it.
-Jeff
Q. I need information on how to get success/failure? Do I look for an exception on failure or can I get a count of 'affected' records (old school?)
If it doesn't throw an exception then it's worked
Q. If I get an exception, which exception(s) can I expect?
You can expect a DbException
We don't use custom exceptions. I spent 5 weeks writing docs - so yah I did spend some time on this. You could also find your answer there as well: http://subsonicproject.com/docs
3.0 is a little too buggy for me so far. I think I am going back to 2.x for now, thanks for all the hard work though.
Related
I am new in memchached concept. I search everywhere but i couldn't find anything how to implement in ASP.net 4.0. Can anyone tell me about the right concept.
I successfully installed memchached Server in services.msc
Now what to do after this step.
can any one have good example in Asp.net. If yes, Please provide me.
OR Please tell me step by step code.
I also read these article
http://rsuharta.wordpress.com/2011/04/27/memcached-provider-in-the-net-web-application/
But didn't understand anything. Please provide me best solution
Thanks.
Here is a CodeProject article walking you through using memcached in an ASP.NET application.
However, let me first say that it's awful likely that if you don't already understand the concept of a framework like memcached you don't need it.
Let me try and make this as clear as possible so you can make the right decision. For some reason, as of late, data caching has become the new "golden hammer" and all kinds of frameworks have popped up. But the problem is that most developers don't understand the real driving forces behind implementing data caching and they don't understand that it's really not a trivial matter. I'm going to give you the same example I gave someone else just yesterday on SO, but a paraphrased version.
Imagine if you will an application stack (i.e. more than one application) that accesses a shared set of data at a rate of more than, and I'm going to give you the real number, 40M+ transactions per day. Now, when I use the term transaction here I really mean read or write. Which only complicates things BTW because now I have to optimize for both.
Alright, so now we have a set of applications accessing this shared data at a ridiculous rate per day - how do we ensure reasonable response times for both read and write? Data caching. But, if you're not sitting in that boat you probably don't need data caching and need to spend your time learning other things that are more relevant to what you're doing.
I've been fussing around with NHibernate tutorials for months (yeah...literaly) with no success. I wanted to just get a basic "hello world" level example down pat so I could work with it and massage it into a proper use case but I can never get past the deprecated code or missing library files.
I can only assume that it is me who is at fault because of NHibernate's popularity. Would someone pleeeeeeasee lead me to a self-contained example that I can just download and run? I would absolutely appreciate it.
Many thanks to everyone (with the exception of Diego) for their help. Special thanks to Michael Buen for his suggestion with using Fluent NHibernate.
There is a great example of NHibernate 3.0 in action here that I got to work: http://www.d80.co.uk/post/2011/02/20/Linq-to-NHibernate-Tutorial.aspx
Now all I need to do is learn exactly what's going on and mold it to my uses.
I tried to google but didn't find a decent tutorial with snippet code.
Does anyone used typed DataSets\DataTable in c# ?
Is it from .net 3.5 and above?
To answer the second parts of the question (not the "how to..." from the title, but the "does anyone..." and "is it...") - the answer would be a yes, but a yes with a pained expression on my face. For new code, I would strongly recommend looking at a class-based model; pick your poison between the many ORMs, micro-ORMs, and raw ADO.NET. DataTable itself does still have a use, in particular for processing and storing unpredictable data (where you have no idea what the schema is in advance). By the time you are talking about typed data-sets, I would suggest you obviously know enough about the type that this no longer applies, and an object-model is a very valid alternative.
It is still a supported part of the framework, and it is still in use as a technology. It has some nice features like the diff-set. However, most (if not all) of that is also available against an object-based design, with classes and properties (without the added overhead of the DataTable abstraction).
MSDN has guidance. It really hasn't changed since typed datasets were first introduced.
http://msdn.microsoft.com/en-us/library/esbykkzb(v=VS.100).aspx
There are tons of videos available here: http://www.learnvisualstudio.net/series/aspdotnet_2_0_data_access_and_databinding/
And I found one more tutorial here: http://www.15seconds.com/issue/031223.htm
Sparingly.... Unless you need to know to maintain legacy software, learn an ORM or two, particularly in conjunction with LINQ.
Some of my colleagues have them, the software I work on doesn't use them at all, on account of some big mouth developer getting his way again...
Are there any good libraries or wrappers for Authorize.net? The code samples available from their site seem a little ... raw. I'm looking for an easy to use, object oriented API that I can simply set some properties, and it takes care of all the plumbing code under the hood.
I've found a few random blog posts of people offering their code that they've written, but code offered in a blog post doesn't give a high degree of confidence generally that it's been well tested. I mean, we'll consider these if we have to, but we'd prefer something that looks like it's gone through some sort of release/testing cycle ... even if it's just that it has been posted on codeplex or something.
Thanks! :-)
A little late answering, but perhaps this?
http://code.google.com/p/payment-processor/
I use SharpAuthorize.com on a few eCommerce sites. One of which makes around $10K / month...
MinimumCreditCard authNet = new MinimumCreditCard()
.Login("testdrive")
.Password("password")
.TransType(TransType.AUTH_CAPTURE)
.CardNum(_cardNumField.Text)
.ExpDate(_cardExpField.Text)
.CardCode(_cardCodeField.Text)
.Amount(8.00);
if (authNet.Authorize())
{
// Money in your pocket!
}
It is noted on the site, but you should use a transaction id instead of the username and password in real code.
See my answer here, it should help you out. In my answer, I point to a blog post as a reference. You may need to view the revisions to see my whole answer, though. For some reason it is getting cut off for me. Check out the Gateway Provider Implementations section of the blog post. It should help you out and get you going on implementing your own code for talking to the Authorize.Net API. I've used a similar implementation and it has worked well for me.
Relating to another question I asked yesterday with regards to logging I was introduced to TraceListeners which I'd never come across before and sorely wish I had. I can't count the amount of times I've written loggers needlessly to do this and nobody had ever pointed this out or asked my why I didn't use the built in tools. This leads me to wonder what other features I've overlooked and written into my applications needlessly because of features of .NET that I'm unaware of.
Does anyone else have features of .NET that would've completely changed the way they wrote applications or components of their applications had they only known that .NET already had a built in means of supporting it?
It would be handy if other developers posted scenarios where they frequently come across components or blocks of code that are completely needless in hindsight had the original developer only known of a built in .NET component - such as the TraceListeners that I previously noted.
This doesn't necessarily include newly added features of 3.5 per se, but could if pertinent to the scenario.
Edit - As per previous comments, I'm not really interested in the "Hidden Features" of the language which I agree have been documented before - I'm looking for often overlooked framework components that through my own (or the original developer's) ignorance have written/rewritten their own components/classes/methods needlessly.
The yield keyword changed the way I wrote code. It is an AMAZING little keyword that has a ton of implications for writing really great code.
Yield creates "differed invoke" with the data that allows you to string together several operations, but only ever traverse the list once. In the following example, with yield, you would only ever create one list, and traverse the data set once.
FindAllData().Filter("keyword").Transform(MyTransform).ToList()
The yield keyword is what the majority of LINQ extensions were built off of that gives you the performance that LINQ has.
Also:
Hidden Features of ASP.NET
Hidden Features of VB.NET?
Hidden Features of F#
The most frequently overlooked feature I came across is the ASP.net Health Monitoring system. A decent overview is here: https://web.archive.org/web/20210305134220/https://aspnet.4guysfromrolla.com/articles/031407-1.aspx
I know I personally recreated it on several apps before I actually saw anything in a book or on the web about it.
I spoke to someone at a conference one time and asked about it. They told me the developer at MS had bad communication skills so it was largely left undocumented :)
I re-wrote the System.Net.WebClient class a while back. I was doing some web scraping and started my own class to wrap HttpWebRequest/HttpWebReponse. Then I discovered WebClient part way through. I finished it anyway because I needed functionality that WebClient does not provide (control of cookies and user agent).
Something I'm thinking about re-writing is the String.Format() method. I want to reflect the code used to parse the input string and mimic it to build my own "CompiledFormat" class that you can use in a loop without having to re-parse your format string with each iteration. The result will allow efficient code like this:
var PhoneFormat = new CompiledFormat("({0}){1}-{2}x{3}");
foreach (PhoneNumber item in MyPhoneList)
{
Console.WriteLine(PhoneFormat.Apply(PhoneNumber.AreaCode, PhoneNumber.Prefix, PhoneNumber.Number, PhoneNumber.Extension));
}
Update:
This prompted me to finally go do it. See the results here: Performance issue: comparing to String.Format