aussie coder . com

Tag: .NET

Entity Framework – It’s the little things…

by Andrew Tobin on Aug.18, 2010, under Uncategorized

So I have been working with Entity Framework for a short time on a sekrit projekt at the moment and even just with my beginner experience, and very limited need for special features, I keep running into issue points, so I thought I’d enumerate some here.

Now, for reference, I am using Entity Framework 4, CTP4 aka Magic Unicorn Edition.

1. Guid Primary Keys with Clustered Indexes.

You can probably find a lot of guidance online about why you don’t want Guids in a clustered index, but the basics are that with a clustered index, it tries to keep the index sorted, and Guids by their very nature are random.

So what you’re doing is, every time you insert or delete a row into your table, using an object that has an ID with a type Guid, it makes the SQL server work to find the right place to do the insert, puts the row in, and then has to re-sort the index to be correct.

The correct behaviour would be to keep it as Primary Key, so the Guid/uniqueidentifier is unique, but to have a non-clustered index – which means the key is still indexed, it can still find the key quickly and efficiently, but it doesn’t make the server work to keep it sorted in order.

The way it stands now, the Clustered Index will cause severe performance issues when as the amount of data in your database increases.

I have listed a Microsoft Connect article here to fix the issue.

The guidance I got from one of the team was to include some DDL scripting to drop and recreate the index, or make my own EF Provider, as a wrapper around their provider, to do the table creation properly – but I would like to see them fix this, as most of us would just accept what Microsoft are doing as correct.

2. The ability to Exclude properties from mapping to the Database.

Say for example, I have a property that I require in my object model for the view – say I want to collect the user’s email address, so I can create a Gravatar string (which is an encrypted hash of the email address) and then just save the string in my database, and not have to store their email anywhere.

Well, at the moment, whatever is in my object model will get mapped to the database (and if I allow it, Entity Framework will automatically create the database table with the email address in it.

There seems to be two ways around this at the moment:

1) Create the property with no setter, so it is read only.
2) Create the mappings by hand.

In the first instance, I cannot populate the address from the view, which makes it unusable, and in the second, I would have to manually map the other 40 properties, in code, and make sure I remember to update or map any future changes and additions.

The alternative would be for them to add another attribute, so I could do something like:

[Exclude]
public string EmailAddress { get; set; }

As far as things go, it’s a difficult learning process, as most guidance out there seems to be around the older way of doing Entity Framework, using model-first or at least the model designer.

I would love to see more information on dealing with POCO classes and the CTP4 out there, in an more centralised fashion, through the group’s blog or some better screencasts.

For example, finding information about how to change the schema prefix from “dbo” to your own, in EF seems impossible – I have a few ideas to try, but at the moment, it’s not the easiest framework to get into for a n00b.

I’ll possibly update this post as other issues come up, but if you have any suggestions on how to get around some of these problems, that I’ve overlooked – feel free to leave them, or links to helpful resources in the comments.

Leave a Comment :, , more...

Why the User Group is Good For Me

by Andrew Tobin on Aug.20, 2009, under Uncategorized

Recently our local user group has had a bit of a break period – it’s relatively small and we had all burnt out a bit – especially those of us who are constantly presenting.

We returned last month, to basically an intro C# video fest, but it’s got me a little introspective.

I think the best times I have had to learn recently is when I have been cramming to learn something enough to pass on a somewhat educated review at the user group.

I won’t say I’ve learnt anything in depth that I’ve presented – even LINQ I feel like I’m swimming in the shallows of it, but that’s all I have needed day-to-day at work, and in contrast to the guys who don’t get to develop with these tools often, I do feel slightly more advanced.

So what I am thinking of doing, and blogging to at least get it down to motivate me – is to learn a topic a month.  Choose some technology I have been hearing about, and devote enough time that I’d be happy to present some of the basics of it, over the course of a month.

That’s not to say I wouldn’t be learning other things – but I’d try to devote a bit of blog space, actually blog the links and sources I use online and discuss things in more detail.

Anyway, that’s the plan, so I’ll start with the new month!

Any suggestions?

Leave a Comment :, more...

KISS -> Finding a better way

by Andrew Tobin on Jan.30, 2009, under Uncategorized

Everyone should know now that KISS is Keep It Simple Stupid, but basically I was working away on a project at work and what we needed was a graphical line chart that displayed the growth based on user input, to give them some visual feedback of the curve they were entering.

I started very complexly using Stack and LinkedList, making my own methods to validate and add and remove segments so that the whole thing would work cohesively, and then it was pointed out to me that we didn’t really need to take into account both ends of each segment, we might as well just treat it as the next segment takes its start from the last.

So I simplified my objects all the way back to a simple list and a validator on submit – but that left how was I going to do the graphing?

It’s in a winforms .NET application, so I thought maybe there was a graphing library, or I could use lines and the drawing primatives, but I needed some values on the axis and all that.

Anyway, had a quick think and came up with the ReportViewer control! We already use Reporting Services for a lot of our reporting and the users are familiar with that, but I’d never done it with an in-memory set of data, using the local version.

Half an hour later I had a spiked test version done and ready for smoothly bringing it back into the main project.  Seriously, I had visions of such complexity, for something that could resolve itself so easily, and the boss had no qualms about using that control in the production application.

Sometimes you just need to take a step back and stop banging your head on the desk long enough for the ideas to come through to you – and remember to keep things as simple as possible and they’ll often work.

1 Comment :, , , , more...

Code Camp Oz Aggregated News

by Andrew Tobin on Jan.23, 2009, under Uncategorized

Hey guys,

So in the lead-up to the Code Camp in Wagga, that happens around April, I thought I’d put together an aggregated tumbleblog so that news on the lead-up and on the event itself can be found in one place (or at least gets some good links that will provide better Google rankings for those that make the effort).

So what I’m planning on doing there is subscribing to any Google blog search rss entries that mention Code Camp Oz, any twitter entries marked #ccoz, any flickr photos marked ccoz, and whatever else I can find along the way.

If anyone has any suggestions on posts to add at any time to the feed, or another site to aggregate in, then please forward them on to me.

The link blog can be found at: http://ccoz.tumblr.com/

Leave a Comment :, , more...

Another Community Email List

by Andrew Tobin on Jan.21, 2009, under Uncategorized

Just a follow up on yesterday’s post.

There is another Aussie Dot Net Email list that seems active over at: http://groups.google.com.au/group/ausdotnetlist

I’d suggest if you want to subscribe however, to open up one of the emails on there and use the email subscription link, as Google groups only wanted to allow me to subscribe to the daily digest and not individual emails – and it seems hosted elsewhere.

Leave a Comment :, more...

A Thought on the Aussie .NET Community

by Andrew Tobin on Jan.20, 2009, under Uncategorized

I was having a talk on this the other day with Matt Hamilton during work, but how active would you say the Australian Development Community is today?  Is it more or less active than a year ago, or two years ago?

Mitch Denny and the guys do a fantastic job of giving us Code Camp Oz every year, and same goes for Greg Low and the SQL Code Camp but the rest of the time I think it’s gone pretty quiet (although I don’t get to go to Tech.Ed).

Maybe it’s just me, but since Frank Arrigo moved to Seattle the old Tech Talk Blogs has died off, the last post being over two years ago, everyones moved on to Twitter to a large degree and blog posts “feel” less regular, and I was just wondering if it was a general impression that I’ve gotten or whether it’s something felt by others as well.

For the record, the Microsoft guys I’ve seen or talked to on Twitter are still a bit active and Nick Hodge has offered to come out and talk to us at the Albury/Wodonga .NET Users Group in the past (Dave Glover has actually been to see us in the past also), but I can’t even name the guy that replaced Frank at Microsoft for the Australian Dev community.

That being said, I don’t belong to any of the email groups or anything around.

So I have to ask the question, for anyone who stumbles across this blog, is the Aussie Dev community getting quieter, or is it just my perception of it?

Any recommendations on where the conversations are happening?

Edit:

And in a case of FAIL on my part, Frank Arrigo had actually posted about the new head of Microsoft’s Developer and Platform Evangelism division, Gianpaolo Carraro, the day before I posted this, but I was on the road and only just caught up on my feeds!

4 Comments :, , more...

Australian Alt.NET Group

by Andrew Tobin on Jan.19, 2009, under Uncategorized

So there is a new series of Alt .NET groups started up for Australia in the capital cities (namely Sydney, Brisbane and Perth).  You can find them at this address: http://ozalt.net/

There is also an email list going on that is not too active at the moment but might gain momentum.

I’m a bit surprised to see the groups created, although I know there is a great interest in furthering learning for development in Australia, as witnessed by the amounts of people that travel from all over the country to attend Code Camp Oz, I wouldn’t have thought there was a whole lot of interest in segregating these groups apart from the Dot Net User Groups already in existence.

I know that the *DNUG system does have some ties to Microsoft, even though our local group has only received passing support occasionally from Microsoft – although they’ve asked if we wanted presenters, it’s not like they have that much to do with us.

But I wouldn’t have thought it’d be that important to start new groups, when I’d personally prefer to see the same ideas behind Alt.NET brought back into the *DNUG groups.  I know in our small group we couldn’t sustain a second group for the township – as well I know that the guys in the group would be open to presentations on anything that could help their .NET development, be it Microsoft technology or anything else.

Anyway, I guess the guys who are behind this have their reasons and I wish the groups well, and hope to hear good things coming out of them – it’d be interesting to see some Aussie guys get involved visibly in the Alt .NET community.

And hopefully some of them might have a session or something back at the Code Camp to let the rest of us know what they’re about!

Leave a Comment :, , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Archives

All entries, chronologically...