#2102 surely put on one amazing show, comparable to her stablemate, former GM&N #425, as she powers down the tracks on the hot and humid July day. In this production, we get to see newly restored T1 #2102 hauling the second Iron Horse Ramble Excursions on Andy Muller's Reading & Northern Railroad, based out of Jim Thorpe, PA. Of which this class, four have been preserved, #2100, #2101, #2102, and #2124, each of them having their own excursion careers. Arguably the most famous of the anthracite haulers would be the T-1 4-8-4s, the Reading Company's home-built northerns. The Reading Company was of many railroads that helped transport this precious resource. This helped shaped Pennsylvania into what it is today.
Reading #2102 - King of the Anthracite Arkansas Locomotive Works | Anthracite has been mined in the Pennsylvania Appalachian Mountains since 1768.
TRAINZ CUMBERLAND TO CONNELLSVILLE TANE CODE
I have a general distaste for decorating my code with Attributes and Annotations.©2022 Home Trainz A New Era: K&L Trainz CN S1-B 3254 VS US Locomotive Works CN 2-8-2 3254 Arkansas Locomotive Works 8:17 | Updated 6 hours ago. Most of the time, I can’t help but feel like there must be a better way to accomplish what I am trying to do, and/or that I have somewhere sprung a leak in what should be a helpful abstraction. Other times, though, custom attributes can be just the tool for the job, and sometimes, the only practical way to solve a problem.Īn easy to understand use case for Custom Attributes might be the mapping of object properties to database fields in a data access layer. You have no doubt seen this before when using Entity Framework. In EF, we often utilize to decorate the properties of our data objects. Use Custom Attributes to Give Hints or Property Metadata Additional Resources and Items of Interest.Custom Attributes Can Be an Architectural Trade-Off.Cache Results from Calls to Reflection Where Appropriate.Use Custom Attributes to Map Properties to Database Columns.Use Reflection to Examine the Properties and Attributes of an Object.Here, we’re going to take a quick look at creating our own custom attributes. ComponentModel.DataAnnotations namespace provide a ready-made means to do this, but for one, you may find yourself building your own data access layer or tool, and for another, this is an easy-to-understand example case. Let’s see how we might implement our own version of these data annotations as Custom Attributes. “But John,” you say, “Entity Framework already does this!” Var mapsto = columnMapping as DbColumnAttribute Ĭonsole.WriteLine(msg, property.Name, mapsto.Name) FirstOrDefault(a => a.GetType() = typeof(DbColumnAttribute)) For example, if we wanted to implement our own Attribute to indicate that a particular property on a class in our application represents the Primary Key in our database, we might create the following Custom Attribute: public class PrimaryKeyAttribute : Attribute database column" To create a Custom Attribute in C#, we simply create a class which inherits from System.Attribute. Believe me, you may not always have EF at your disposal. Also, you WILL run into databases “in the wild” where column naming conventions do not align with C# Class and property naming conventions (Work with a Postgresql database for five minutes, and get back to me). Cache Results from Calls Using Reflection Where AppropriateĪ quick note, which is only marginally applicable to the examples above, but important in the design of a real-world application. Calls to using reflection can be expensive. Overall, machines these days are fast, and generally, the odd call to GetType() and GetCustomAttributes() are not all that significant. Except when they are.įor example, if the above code were used in a larger application context repeatedly, it might be better to walk through the object properties at object initialization (or even at application load) and map the object properties for each to its respective column name and stash them all in a Dictionary.
Then, anywhere in your code where the mapping is needed, you can access the primary key name for a specific object by use of the property as a key. AG GRID MAPPING THE THE ATTRIBUTES EXAMPLE CODE
How you do this and where would depend heavily on what you are doing, and the larger structure of your application.