As far as I have seen content controls in Office 2007 render to either a SdtRun or SdtBlock object. The nice thing is that both of these inherit from SdtElement. This allows you to take the query from my earlier post and replace SdtBlock with SdtElement and now you have a universal retrieval. Of course as with any tool you need to be careful you don’t take it too far. Depending on the structure of you document this may not do what you need. Technorati Tags: office Open XML,OOXML,LINQ,.NET...
If you are using a template document and replacing text programmatically using the Office Open XML SDK 2 API you will need a way to identify the target to be replaced. One option is to use a Content Control and setting the tag value the same for all of the controls that need to be substituted with a single value. After some trial and error and a lot of digging through the DocumentReflector I came up with the following LINQ query to get a list of all blocks with the same tag name. var blocks = from...
While I was planning to write about the same topic and have the draft ready in my Windows Live Writer waiting to complete, I found an interesting question in StackOVerflow and couldn’t just resist to answer: ORM/Persistence layer Advice The question starts with: I'm starting a new project and I'm looking around for either a very good ORM or for a non-SQL-based persistence layer. Then follows up with a REALLY GOOD summary of what he believes about each known ORM he knew out of his own findings and...
It took a bit for me to get comfortable enough with LINQ-to-objects to write ‘queries’ off the top of my head…but once you’re used to it you realize it’s much more concise, easier to interpret/read, and well..it’s less code. Here are some real quick examples… This first example selects the string array value as well as its position from the someItems array. Note, the user of new{} creates a new generic type that has the properties ItemName and Position. I could have called these two properties whatever...
One of my colleague remarked that LINQ is "VERY SIMILAR" to TSQL. However, he also cursed that why the LINQ guys have implemented it "reversely". What he meant that why the Select is reversed… SQL query will be 1: Select Name from Employee where sal > 80000 LINQ 1: var q = from emp in Employee 2: where emp.sal > 80000 3: Select emp; I cant help but giving him references to Korth & Sudarshan and mathematical Projections… That also reminded me of taking a quick tour of algebra which i am...
Just a quick tip that I found handy while doing some writing yesterday; chances are if you’ve played with LINQ you probably wrote something like this… var outputString = from s in inputString where s.Length > 1 select s; //Do some stuff with outputString in your method... Code like the above will work perfectly well if what you’re going to work with your implicit variable, outputString, within the body of the same method. But, as it stands, you can’t return outputString, or any implicit variable...
Allow me to quote here some emails I sent to the the Dot NET developers group in my company, Injazat, or, as we call ourselves, Ninjazat. I thought it’ll be useful to share some with you as well. · ASP.NET MVC - 20 Hours of FREE Video Tutorials · LINQ FAQ o LINQ FAQ for Newbie’s o LINQ FAQ Part 2 · How we handle application configuration · ScottGu ASPNETMVC Session Video Available Now (Part 1/2 & 2/2) · Web Validation: Best Practices and Tutorials · Building a Single Sign On Provider Using ASPNET...
Recently I have been doing some work on an older system using ADODB recordsets. Every now and then we still have to support these old systems. I wanted to create an open recordset in code on the .NET side to pass to the older system, but ADODB really wants an open database connection in order to open a recordset. My first obvious attempt was to create the recordset object, then create the field objects and add them to the recordset. I could create the recordset this way, but I couldn't open it, and...
Not too long ago, I spared some time to discover the hype of LINQ, primarily, LINQ to SQL. I was amazed of how much faster I could get things done with much less code. In fact, I’ve converted much of Glacsy.com to using LINQ and have noticed a HUGE performance increase from the server. The websites load faster, an area in which we’ve been targeting and trying to improve since the new rebuild of the sites. I may post a few examples to include LINQ in the future. Tags: LINQ...
Just in case you missed the news, Yahoo has created it’s own query thingy. No, no LINQ provider, it’s a “query language”. Check it out! http://developer.yahoo.com/yql/ Quote: What is YQL? Yahoo! makes a lot of structured data available to developers, primarily through its web services. These services require developers to locate the right URLs and documentation to access and query them which can result in a very fragmented experience. The YQL platform provides a single endpoint service that enables...
If you don’t know what eager loading is, Jump to “What’s eager loading?”. Eager Loading Syntax If you are eager loading Products for example in a typical (Categories 1<->* Products) relation, the standard syntax would like: DbDataContext.Categories.Include(“Products”) What is the problem with that? The “Products” part. The word “Products” is a string. If I rename the Products table to ShopProducts or whatever or even remove it from this data diagram and have it elsewhere, or even something...
A couple of weeks ago, I was working on some client side UI elements on one of my projects. I was able to apply some things that I have learned recently (some more recently than others). The problem is that I have a domain object that tracks the selected days of the week. Currently the object uses a List<DayOfWeek> to manage the selections. (This is not exactly the most safe thing because a client could set the list to null. However, that's a different subject.) What I was looking for was an...
Suppose you have three tables in your database where one of them specifies a many-to-many relationship between the other two (example from AdventureWorks): Suppose also that you have a method such as GetVendors(int productID) that will retrieve all the vendors for a given product through the ProductVendors table (that is , the many-to-many table). Now, if this method is exposed via a WCF service, when your client calls it you will see an exception like this one: "System.ServiceModel.CommunicationException...
Absolutely brilliant. That's what I think of Linq to XSD. Disappointed that is only works in C#, but having to use C# for a single project out of a solution it is a small price to pay to get the functionality. If you install the LINQ to XSD Preview Alpha 0.2 Refresh you get a couple of extra project definitions: If you create one of these it will have the features enabled. You can add the features to an existing project by editing the project definition file to add a property group: 1: <PropertyGroup>...
I have a situation where I want to use a transaction to keep track of a particular message process in order to roll back various parts if there is a failure. The service operation is listening on a queue using the NetMSMQBinding and the operation is marked with the transaction properties of the OperationBehavior like so: <OperationBehavior(TransactionAutoComplete:=True,TransactionScopeRequired:=True)> Public Sub SendHello( ... Using the above attribute enables the operation for transaction...
LINQ goes so much further than just SQL and XML. Something like this is just why I love LINQ, a LINQ query on an ASP.NET ListView controls items. 1: Dim items = From lvi In AspNetListViewControl.Items _ 2: Where CType(lvi.FindControl("DropDownList1"), DropDownList).SelectedValue = someIntVar _ 3: Select lvi) Getting a ListViewItem's where the selected value of a DropDownList is set to the value I want. So simple, yet so powerful. The observant among you will notice that this is in VB.net, not my...
I had the opportunity today to write some more complex LINQ queries. First, I started with a simple group by expression allowing me to subtotal some data for a particular key. Certainly I could have done this in the database. Many would argue that that the database is the expert at these sorts of things, so we should let the expert take care of it. I have a couple of reasons for placing the group by in the LINQ query. First, I don't have a lot of control over the data layer. Second, I can unit test...
I have recently came up against a perfect opportunity to get stuck into LINQ to SQL, its a small project where RAD is top priority. As often is the case I need to audit changes to properties, normally I would probably do some work in the getter and setter of the property, but of course with LINQ to SQL I don't have access to the properties in the same way. Looking through the intellisense of the LINQ generated class I can see a PropertyChanged and PropertyChanging event, perfect! Not exactly. Here...
This is the email I sent to SilverKey Tech. Egypt dev team yesterday, sharing here as usual. Article: Info Q: Don't Let Consumers and Service Providers Communicate Directly Just because someone is developing with Web Services does not mean they are following SOA principles Just because you're using HTTP and HTML doesn't mean you get into that camp and vice versa Weblog: "Making IT work" - Musings of a Holistict Architect Weblog: Udi Dahan Article: Autonomous Services and Enterprise Entity Aggregation...
While playing with Linq and trying to get it to work with Oracle (Linq to Oracle *sigh*), I struggled with the fact that Linq appears to tightly couple business objects with data/persistence. I found myself pondering this fact and trying different approaches to separate the ObjectContext from EntityContext(s). In Linq, the ObjectContext is the object that you provide with a connection string and has the knowledge to send/receive data to/from your database. The EntityContext(s) are the classes that...
Well, I have been playing with Linq, specifically with Oracle. First of all, the only way I could find to make this work is to use a third party software, OraDirect.Net by Core Lab. Their product is great. Perhaps that statement is biased by the fact that they are the only one's building a library to support Linq to Sql (as far as I know). There is certainly room for improvement. I've crashed VS a few times because I was trying to force OraDirect to do something it doesn't support. So, error handling...
The "C# 3.0 in a nutshell" book has some neat free extras that are worth mentioning for those who haven't already heard of (they have been released for long). Those are like must-have LINQ tools and helpers. The homepage of LINQKit (the major part of the extras I'm going to cover here) provides great information and short code samples about the components: LINQPad This is a snippet compiler (application to run/try small codes in separation than big VS projects, like this), that's customized for LINQ...
improve my => 'code' I just started playing around with LINQ seriously, and I really love some of the features incorporated, like the Enumerable.Range() function and how it can be used for integer programming. Here's a simple function for generating lognormal distributions (could be useful for financial engineering). Hope you're enjoying the samples, Jonathan Starr public List<double> GenerateLogNormalDistribution(int numberOfTimes, double mean, double standardDeviation) { Random randomGenerator...
Few hours ago, Michael Schwarz, the creator of AJAX.NET Professional (A.KA. AJAXPro), the most successful AJAX framework for ASP.NET after Microsoft's ASP.NET AJAX Framework (A.K.A., ATLAS) has stated that he'll no longer be working on the project. Furthermore, he even recommended users to move to Microsoft's AJAX Framework instead!! The reasons Michael mentioned why he will stop the project used by 13.3% of ASP.NET developers doing AJAX work include the fact that ASP.NET AJAX is part of ASP.NET...
Today is the primary day of Muslim's ADHA (Sacrifice) feast. I'm enjoying it with family activities in my grandmother's house and few hours later my uncle's house. Thanks God both have wireless Internet connectivity. This how I could still check my Google Reader items (see shared items), while showing my profile pictures to my uncle's little daughter and other kids from the family! Then I noticed that the feast has a great gift, coming from Microsoft this time. I found that Microsoft has opened 3...
If you are not familiar with the new LINQ syntax in .NET 3.5 I recommend you read up on that first. Language Integrated Query (LINQ) is the new foundation for querying anything (I mean anything) in .NET and a lot of effort has been put into LINQ and XML integration. I did some research a few months back on it but it was only recently that I realized how much Microsoft put into LINQ to XML. I am a huge fan of intellisense. That is the best thing that MS ever perfected in Studio. I spend a lot of time...
In my quest to play with test VB 9.0 and it very cool features I created a little application to update Active Directory. I was asked by my boss (Andre) to get some sense of order into Active Directory for the users that will be involved in the proof of concept for MOSS 2007. So I immediately thought of an application to automate this. The idea was to pull the information from AD for the selected users into a database and then make all the changes that are required there before updating AD with the...
You are all undoubtedly aware of LINQ to SQL, its fair to say its had a large amount of publicity and coverage in the .net circle. VS 2008 makes getting going with LINQ to SQL very easy but that is not the case with SQL Compact (yet!). However its not difficult if you have heard of a wonderful little app called SqlMetal, this little beauty will generate the .dbml files for you...happy days :) I have a small SQL Compact database to use for this demo, you can see it here in VS 2008 server explorer......
I decided that I should have a go at this LINQ thing, so as .NET 3.5 will be RTM at the end of the month I am using LINQ and .NET 3.5 in my new Locator project. The Locator project is just a small application that will run on a users computer and tell a central server where they are. In Aggreko we have the problem that people are moving about a lot (everyone has a laptop) and when you are looking for someone you need to be able to find them. The application sits and poles the IP address of the local...
DonXML starts this conversation with a recap of ALT.NET, then breaks into the new technologies Microsoft is releasing in the area of XML. Don has been an XML MVP for the past 4 years and is definitely one of the brightest in this space. Read his blog here. Listen to DonXML talk about XML! Technorati tags: HDC, DonXML, LINQ, ALT.NET, VB, XML...
The first problem I have encountered in that in the past I have had various version of Office 2007 beta and other bits and bobs. You will need to remove these to install Visual Studio 2008 Beta 2. If your install fails on or just after "Microsoft Web Designer Tools" then you probably have this problem. If you download the Windows Installer Cleanup Utility you will be able to clean anything that is Office 2007 and beta from you system. This worked for me, but I guess you may have other problems......