Archives
-
Entity Developer Review, Part 4
This is my fourth post on Entity Developer, Devart’s O/RM tool for NHibernate, Entity Framework and LINQ to SQL. The first post was an introduction to Entity Developer and a general description of its usage, the second was focused on NHibernate and the third on Entity Framework. This time I am going to cover some aspects that were not mentioned in the previous posts.
-
Entity Framework Pitfalls: Non Public Entity Sets Setter
Updated
-
Microsoft Unity Succinctly
-
Entity Framework Pitfalls: String Length Validation
If you want to validate the maximum number of characters that a string property can take, you might be lured into using MaxLengthAttribute. However, this won’t give you what you want: what this attribute does is, when a model is being generated, it provides the maximum length of the string field in the database, but does not perform any kind of pre-insert or pre-update validation. For that, you need to use StringLengthAttribute. This one is indeed a validation attribute, inheriting from ValidationAttribute, and will be called when EF is about to persist your entity, or when ASP.NET MVC validates a model as a consequence of a post. You can specify both the minimum (MinimumLength) as well as the maximum length (MaximumLength).
-
Entity Developer Review, Part 3
Here is part 3 of my exploring Entity Developer series, this time, on Entity Framework. Read the first part here and the second here.
-
Lesser-Known NHibernate Features: Validation and Lifecycle Interfaces
NHibernate offers two interfaces that can be used to validate an entity before it is saved or updated or to cancel its saving, updating and deleting: IValidatable and ILifecycle. They are an alternative to events, and don’t need anything else to work other than be implemented by some entity.
-
Entity Developer Review, Part 2
Here’s my second post on Entity Developer, this time, focused on NHibernate. You can find the first part here.
-
Microsoft Azure Development Cookbook Second Edition Review
-
Entity Developer Review, Part 1
I recently started to use Entity Developer, by Devart, to generate entities from my databases. It is a commercial product, mind you, and I am in no way affiliated with them, I just happen to like it, so I am going to talk a bit about it.
-
Filtering and Sorting SharePoint List Views
-
HTML Tags in XSLT Variables
Sometimes there is the need to show text inside HTML tags. For instance, in one occasion, I wanted to show just a portion of the contents in a Wiki field, but just the text. xsl:value-of will return the contents inside HTML tags:
-
Broadcasting Database Changes Through SignalR
There are several posts out there on using SignalR to signal changes in a database, but because I really didn’t quite like any of them, I decided to write my own.
-
SharePoint References
I just updated my Excel I mentioned before with lots of hopefully useful SharePoint references:
-
The SPDataSource Control
SPDataSource, together with XsltListViewWebPart, DataFormWebPart and ContentByQueryWebPart, is one of the most powerful tools that SharePoint provides. Because it can be used in different ways, it can also get complicated. In this post I am going to talk about is different modes and what can they give us. Fist, you need to know that the mode comes from the DataSourceMode property and can be one of:
-
Entity Framework Pitfalls: Collections of Types Other Than ICollection<T> Are Ignored
If you expose in your entity a collection of a type other than ICollection<T> (or one inheriting from it, such as IList<T>) then it will be ignored. This is a bit absurd, because you might want to expose a collection as read only, where you would probably use IEnumerable<T>. For the record, NHibernate allows that.
-
Lesser-Known NHibernate Features
Updated on October 5th.
-
NHibernate Pitfalls: HQL Queries With Joins
This is part of a series of posts about NHibernate Pitfalls. See the entire collection here.
-
Lesser-Known NHibernate Features: Proxy Generation
Did you know that you can leverage NHibernate’s built-in proxy generator to inject custom behavior in your classes? It is called NHibernate.Proxy.DynamicProxy.ProxyFactory and there’s an interface, NHibernate.Proxy.DynamicProxy.IInterceptor, that you can use to extend it, by intercepting method and property calls.
-
Lesser-Known NHibernate Features: Serializable Values
If you want to store anything in a property of an entity, you can declare it as Object or dynamic; as long as you set it to a value of a serializable type, as supported by BinaryFormatter, you’re good! You can even change the value afterwards to a different type, and it will be saved.
-
Speech Recognition in ASP.NET
Speech synthesis and recognition were both introduced in .NET 3.0. They both live in System.Speech.dll. In the past, I already talked about speech synthesis in the context of ASP.NET Web Form applications, this time, I’m going to talk about speech recognition.
-
Loading ASP.NET MVC Controllers and Views From an Assembly
Back to MVC land! This time, I wanted to be able to load controllers and views from an assembly other than my application. I know about the extensibility mechanisms that ASP.NET and MVC give provides, such as Virtual Path Providers and Controller Factories, so I thought I could use them.
-
ASP.NET NHibernateDataSource
A long, long time ago, I wrote a NHibernateDataSource control. Back then, it was based in the first LINQ provider for NHibernate, and a long has happened since. Now, I decided to give it another go!
-
Entity Framework Pitfalls: Registering Custom Database Functions for LINQ
Like I said in my previous post, it’s not enough to add a DbFunctionAttribute attribute to a method to have it call a database function. If the function is not a built-in one, it will not be registered in the Entity Framework provider manifest for SQL Server, so it will require registration in the model. You might think, just by looking at the methods in SqlFunctions that all that it took was to add this attribute, but you would be wrong.
-
Registering SQL Server Built-in Functions to Entity Framework Code First
It is possible to register custom functions that exist in the database so that they can be called by Entity Framework Code First LINQ queries.
-
Getting the Current User in SharePoint XSLT
SharePoint offers a couple of ways by which we can obtain the current user for use in a XSLT web part like DataFormWebPart or XsltListViewWebPart. All involve first setting parameters through the ParameterBindings property:
-
Book Reviews
This page will list all of my official (books for which I was the, or one of the, tech reviewers) and unofficial book reviews, in no particular order.
-
Show All Content in XSLT
I have already shown how you can display all attributes and their values from a XSLT content, but in case you want to look at the whole structure plus their attributes, you can use this instead:
-
Access Navigation Nodes in SharePoint XSLT
SharePoint relies on ASP.NET Site Map Providers for generating navigation links on its default pages. Specifically, the default Web.config file registers a (big!) number of providers, which control different aspects of its navigation:
-
ASP.NET Web Forms Extensibility: Output Encoders
Since version 4, ASP.NET offers an extensible mechanism for encoding the output. This is the content that will be returned to the browser. I already refered it in Providers.
-
Getting the SQL from a LINQ Query in NHibernate
In case you ever want to have a look at the generated SQL before it is actually executed, you can use this extension method:
-
Windows Azure Websites Succinctly
Another book for which I was a technical reviewer in the Succinctly series just got released: Windows Azure Websites Succinctly. The author is Kyle Burns (@kyleburnsdev), who keeps a blog on development at http://geekswithblogs.net/kyleburns.
-
Retrieving SharePoint User Profile Properties in XSLT
A common request is to be able to retrieve user information from XSLT (XsltListViewWebPart, DataFormWebPart, etc). It is possible to obtain some information through server variables (LOGON_USER), CAML variables (UserID) or ddwrt:UserLookup extension function. It works, to some extent, but sometimes it is not enough.
-
NHibernate Pitfalls: Refreshing Manually Created Entities Does Not Bring Lazy Properties of Base Types
This is part of a series of posts about NHibernate Pitfalls. See the entire collection here.
-
Distinct Values in XSLT
How to get distinct attribute values:
-
NHibernate Goodies Coming Soon
Just for you to know that the NHibernate community hasn’t been sleeping, here’s a list of some of the cool new features that are on the queue for the next NHibernate versions.
-
XSLT For Loop
If you ever need to implement a for loop in XSLT, here’s one possibility:
-
Exposing SharePoint Context to XSLT
Picking on my previous post, I am going to show how you can access SharePoint (and ASP.NET context) from XSLT.
-
Editing a Post in Weblogs.asp.net
Updated
-
Displaying All Fields in a SharePoint Data Source
So, you want to know which fields your data source is returning. You can use the following XSLT:
-
Injecting Content in an ASP.NET Web Forms Page From a Module
Modules are a great extensibility mechanism because they allow us to glimpse into a request and to do something before the response is sent back.
-
Custom XSLT Functions in SharePoint
Wouldn’t it be good if SharePoint would allow the registration of custom functions that could be used in XSLT stylesheets? Well, as it happens, it does!
-
A Tour of SharePoint Data Source Controls
Besides the classic ASP.NET data source controls, SharePoint brings along its own. These allow us to retrieve data not just from SharePoint, but also from external sources, such as web services or SQL databases. Using SharePoint Designer you end up using these data sources without even knowing, and, specially, ignoring what other options you have. Let’s look at these controls one by one and see how the can be used. I already talked about the SPDataSource and AggregateDataSource, so I won’t cover these here. I also won’t be covering them in depth, but instead will provide an example of how to use them.
-
SharePoint Field Reference
I know there are dozens out there, but I decided to publish my own field reference for SharePoint. Besides the usual attributes, I include some others, like the SharePoint and CLR type, the enumeration where it is declared (if any), the control used to render it and some more.
-
Aggregating Lists in SharePoint
Another post that could be subtitled “How to do Things in SharePoint By Hand”. This time, combining data sources – lists, in this case, but the same can be applied to other source types, such as SOAP (SoapDataSource) or REST (XmlUrlDataSource) web services, hierarchies of sites (SPHierarchyDataSourceControl), calendar (SPCalendarDataSource), XML files (SPXmlDataSource), BCS external lists (BdcDataSource) or even SQL queries (SPSqlDataSource).
-
Displaying Last Modified Contents in SharePoint
SharePoint, as usual, offers lots of ways to do things. This time, I’m going to show how one can get a list of the last modified contents, in any SharePoint version and edition.
-
Entity Framework Pitfalls: Batch Modifications
Entity Framework does not support batch modifications, that is, UPDATEs or DELETEs of several entities at once. Neither classic nor Code First, not even Entity-SQL.
-
Unity - Part 8: Web
Long overdue in the Unity series, how to use Unity in a web application. You can find the other posts here (Adding Interfaces), here (Registration by Convention), here (Injecting Values), here (Extensions), here (Aspect-Oriented Programming), here (Dependency Injection) and here (Introduction).
-
Displaying Current Weather Status in SharePoint
OpenWeatherMap.org offers a nice service for obtaining current and forecast weather conditions. Go visit it, and search for the “weather in your city”. In the results page, by hovering the link, you will get the id for the city you are interested in; for example, for “Coimbra, Portugal”, it is 2740637 (http://openweathermap.org/city/2740637).
-
TextBox With Suggestions in SharePoint
This control will suggest values for a text box from the values in a SharePoint list. It makes use of the HTML5 datalist element in a slightly customized TextBox control.
-
Adding Markup to a SharePoint Page
How many times have you had the need to add ASP.NET markup – HTML and server-side control declarations – in a SharePoint page? Yes, there is the Script Editor Web Part and the Content Editor Web Part, but none of these allow you to enter server-side control declarations, just plain HTML, CSS and JavaScript.
-
Lesser-Known NHibernate Features: Future Queries
Sometimes it makes sense to send several queries at the same time to the database server. This prevents multiple roundtrips and normally can provide results faster. Knowing this, NHibernate offers two features: multiqueries and future queries. Future queries build upon multiqueries and because they use LINQ, which is probably the most common querying API in NHibernate, I will focus in this.
-
Unity - Part 7: Adding Interfaces
Updated: thanks, Thomas Levesque (@thomaslevesque)!
-
Applying Code Access Restrictions in .NET
Sometimes there is the need or desire to resort to Aspect-Oriented frameworks (AOP) in order to add some validations or cross-cutting concerns. In several situations, it is indeed necessary, but .NET already offers some hooks that we can use to achieve parts of this functionality. One of those is CodeAccessSecurityAttribute. In a nutshell, it allows the application of security checks whenever some code – method, property – is called. A somewhat well known example is PrincipalPermissionAttribute.
-
Lesser-Known NHibernate Features: Entity Mode Map
This one is a real treat!
-
Conditional Content in SharePoint Markup
In SharePoint, there are several web parts that allow us to have different contents depending on some conditions:
-
Lesser-Known NHibernate Features: Mixing Client and Server-Side Calls in Projections
Another not widely known feature of NHibernate: mixing client and server-side calls.
-
Lesser-Known NHibernate Features: Mapping a Class to a Query
Today I start a new series on lesser-known NHibernate features.
-
Nesting SPDataSource Controls
Sometimes, when you are using a SPDataSource control to bind to some list control, you might need, inside of it, to fetch information from the item you are iterating over.
-
Type Conversions in .NET
Updated: followed suggestion to consider the case where the destination type is an interface. Thanks, Asp.net dev!
-
ServiceStack Succinctly
ServiceStack Succinctly is the new addition to Syncfusion’s Succinctly series. It was written by by friend Zoran Maksimovic (@zoranmax), the main author and maintainer of Agile-Code.com.
-
NHibernate Pitfalls: Specifying Property Types
This is part of a series of posts about NHibernate Pitfalls. See the entire collection here.
-
Simple Calculations With .NET
The idea for this post came from a recent post of Salvador Gascon (@salvadorgascon): http://salvadorgascon.wordpress.com/2014/09/27/how-evaluate-math-expressions/.
-
Cascading Drop Down Lists in SharePoint
A common request is the ability to have one drop down list (the child) being filled after another one (the parent) has; this is usually called cascading drop down lists.
-
NHibernate Pitfalls: One Shot Delete and Inverse Collections
This is part of a series of posts about NHibernate Pitfalls. See the entire collection here.
-
NHibernate and the Specification Pattern
My friend Zoran Maksimovic (@zoranmax) of Agile-Code, who was the technical reviewer of my NHibernate Succinctly book (and something else too…), invited me to write a guest post at his blog. The result was NHibernate and the Specification Pattern.
-
NHibernate Pitfalls: Deletes
This is part of a series of posts about NHibernate Pitfalls. See the entire collection here.
-
NHibernate Pitfalls: Get and Filters
This is part of a series of posts about NHibernate Pitfalls. See the entire collection here.
-
NHibernate Pitfalls: Criteria and Collections of Non-Entities
This is part of a series of posts about NHibernate Pitfalls. See the entire collection here.
-
Deleting Entities in NHibernate
This post was motivated by a conversation with Salvador Gascon (@salvadorgascon). Might even go to the pitfalls section… Anyway, the problem is: how many ways there are to delete an entity in NHibernate? And what are the advantages/disadvantages of each?
-
NHibernate Pitfalls: HQL Delete Does Not Cascade
This is part of a series of posts about NHibernate Pitfalls. See the entire collection here.
-
Entity Framework Pitfalls: Date/Time Operations
When using Entity Framework, you cannot perform date/time operations as you would normally do in .NET/LINQ to Objects. For instance, the following query throws an exception:
-
NHibernate 4.0
Recently, the NHibernate team released NH 4.0. You can get it as a NuGet package from https://www.nuget.org/packages/nhibernate, as a ZIP from http://sourceforge.net/projects/nhibernate/ or as source code from https://github.com/nhibernate/nhibernate-core. The full release notes are available at https://github.com/nhibernate/nhibernate-core/blob/master/releasenotes.txt, but here are some highlights.
-
ASP.NET Web Forms Extensibility: Page Parser Filters
ASP.NET includes a valuable yet not well known extension point called the page parser filter. I once briefly talked about it in the context of SharePoint, but I feel a more detailed explanation is in order.
-
NHibernate Succinctly
It’s with great pleasure that I see the release of NHibernate Succinctly, a book that I wrote for Syncfusion’s Succinctly series! It’s my second title, more to come!
-
New Features in SharePoint Designer 2013 Workflows
SharePoint Designer 2013 workflows brought along new and quite welcome features. I will list my favorite ones.
-
Looping Through List Items in SharePoint 2013 Designer Workflows
SharePoint 2013 Designer workflows now has two new interesting options: the ability to call HTTP web services and the option to loop over some code a number of times. This, together with the new REST API, which supports querying lists and returning data in JSON, allows iterating through list items in a workflow, something that was not possible before.
-
Entity Framework Code First Succinctly
It’s official: now I’m a writer!
-
NHibernate Pitfalls: XML Mappings
This is part of a series of posts about NHibernate Pitfalls. See the entire collection here.
-
Blog Changed
This blog has moved to using Orchard. In the next few days, things may not be working exactly as they should; please bear with me, I will try my best to make the transition as smooth as possible.
-
NHibernate Pitfalls: Querying Unmapped Classes
This is part of a series of posts about NHibernate Pitfalls. See the entire collection here.
-
NHibernate Pitfalls: Loading Foreign Key Properties
This is part of a series of posts about NHibernate Pitfalls. See the entire collection here.
-
NHibernate Pitfalls: Fetch and Paging
This is part of a series of posts about NHibernate Pitfalls. See the entire collection here.
-
Getting the Topmost Hierarchical Parent in T-SQL
It is normal in databases to have hierarchical tables, that is, tables that are related with themselves, forming a parent-child relation. For example, consider this:
-
Entity Framework Pitfalls: Deleting Orphans
The idea for this post came from Jimmy Bogard, of AutoMapper fame.
-
Unity – Part 6: Registration by Convention
OK, sixth post on this series, long overdue. You will find the fifth (Injecting Values) here, the fourth (Extensions) here, the third (Aspect-Oriented Programming) here, the second (Dependency Injection) here and the first one (Introduction) here.
-
Video Streaming with ASP.NET SignalR and HTML5
I have already talked about SignalR in this blog. I think it is one of the most interesting technologies that Microsoft put out recently, not because it is something substantially new – AJAX, long polling and server-sent events have been around for quite some time -, but because of how easy and extensible they made it.
-
Taking Picture Snapshots with ASP.NET and HTML5
This is another post on HTML5 and ASP.NET integration. HTML5 brought along with it a number of great JavaScript APIs; one of them is getUserMedia, which is W3C standard and you can get a good description of it in MDN. In a nutshell, it allows access to the PC’s camera and microphone. Unfortunately, but not unexpectedly, it is not supported by any version of Internet Explorer, but Chrome and Firefox have it.
-
Making Better Use of the NHibernate HiLo Generator
NHibernate’s HiLo (High-Low) id generation algorithm is one of the most commonly used, and for good reasons:
-
ASP.NET Callback Panel
Continuing with my quest for reusable, no dependencies, Web Forms AJAX controls, this time I wanted a replacement for the venerable UpdatePanel control. Specifically, I wanted to address the following issues:
-
Speech Synthesis with ASP.NET and HTML5
The .NET framework includes the SpeechSynthesizer class which can be used to access the Windows speech synthesis engine. The problem with web applications is, of course, this class runs on the server. Because I wanted a mechanism to have speech synthesis (text-to-speech) fired by JavaScript, without requiring any plugin, I decided to implement one myself.
-
NHibernate Pitfalls: Aggregating Non-Nullable Numerical Values Without Records
This is part of a series of posts about NHibernate Pitfalls. See the entire collection here.
-
JavaScript Events
A lot has changed with regard to events and event handling since the old days of HTML. Let’s have a brief look at it.
-
ASP.NET Upload Panel
I have been playing recently with HTML5, and one thing that I got to understand really well was the new upload mechanisms available. Specifically, I wanted to understand how SkyOneDrive, Google Drive, Dropbox, etc, all support dropping files from the local machine, and how to use it in an ASP.NET Web Forms (sorry!) project, and I got it!
-
NHibernate Connection Resiliency
Entity Framework 6 included a feature known as connection resiliency. Basically, what it says is, when EF is trying to connect to a database, it will try a number of times before giving up. After each unsuccessful attempt, it will wait some time and then try again. As you can imagine, this is very useful, especially when we are dealing with cloud storage.
-
NHibernate Pitfalls: Outer Joins of Unrelated Entities
This is part of a series of posts about NHibernate Pitfalls. See the entire collection here.
-
Custom NHibernate Criteria Projections
I recently had the need to investigate a way to do some complicated projections with Criteria queries and I was faced with what seems a common problem: being able to fully select the properties of the root entity of the criteria. An issue has been raised on NHibernate JIRA and there are some questions on StackOverflow about it.
-
NHibernate Fluent Validation
Some time ago, I wrote a post on fluent validation for Entity Framework Code First. I think it is a cool concept, and I decided to bring it into NHibernate!
-
On NHibernate Performance
I noticed a flaw here. Will update the numbers in the next days.
-
NHibernate Pitfalls: Table Schema
This is part of a series of posts about NHibernate Pitfalls. See the entire collection here.
-
Minimum NHibernate Code
Sometimes people complain that NHibernate is difficult. Although NHibernate offers a lot of options when compared with other O/RMs, I don’t fully agree with this. Just as an example, all that it takes to setup NHibernate and perform all the mappings, with conventions being applied is:
-
Client Callbacks in Action Part 2 : Self-filling Drop Down List
On the first part of this two-post series I presented a text box that has the ability to suggest values, after a number of characters has been entered. It does this by leveraging the client callbacks functionality of ASP.NET. This time, I am going to show a drop down list that exposes a JavaScript function (fill) that receives a value, and will pass that value to a server-side event also through a client callback where we have the option to populate the drop down.
-
Delete By Id in NHibernate
NHibernate allows executable queries, that is, plain old UPDATEs, INSERTs and DELETEs. This is great, for example, for deleting an entity by its id without actually loading it. Note, that the following won’t give you that:
-
Future Posts
So, a new year is upon us. As part of my new year’s resolutions, I decided to keep on blogging, and, what deserves more attention that what I already started?