Mike Taulty's Blog
Bits and Bytes from Microsoft UK

Browse by Tags

Blogs

Mike Taulty's Blog

Elsewhere

  • ADO.NET Data Services Session at SQL Bits Manchester

    A big thanks to all the people who came along to my session at SQLBits today on ADO.NET Data Services and also to the organisers and community around SQLBits that made the event happen in the first place. I was there for most of the afternoon and it seemed like a fantastic event to me in a cool venue. As promised, my slides from the session are here for download – you’ll perhaps notice that there are a few additional (hidden) slides in the slide-deck that I didn’t use in this talk as I collapsed this talk down from an earlier talk and updated it to reflect the RTM version of Data Services and also the various CTPs/Previews that are currently kicking around. So…you get a little more than I actually used at the conference. Enjoy :-)
  • “Astoria Offline” Alpha Preview Available

    Just a link from me at the moment but there’s a preview of the “Astoria Offline” work that was shown at the PDC now available from here I’m hoping to get time to download it and take a look at it in the near future.
    Filed under: ,
  • Astoria Online/Offline

    Tantalising post from the Astoria team.
  • SQL 2008, Filestream, Docs from VB

    Someone asked me if I had a simple sample of how to read/write documents into a database table using FILESTREAM in SQL Server 2008. I set about it. Firstly, I had to find out how to switch FILESTREAM on in the RTM of SQL Server. At times like this you need Bob Beauchemin to tell you how it's done and then you can go and run code such as this once you've done the necessary bits in SQL Configuration manager; exec sp_configure filestream_access_level, 2 reconfigure go CREATE DATABASE Documents ON PRIMARY ( NAME = DocData, FILENAME = 'c:\temp\docs.mdf' ), FILEGROUP FileGroup CONTAINS FILESTREAM ( NAME = DocFiles, FILENAME = 'c:\temp\docstreams' ) LOG ON ( NAME = DocLog, FILENAME = 'c:\temp\docs.ldf' ) GO and now I've got a database that can accept file stream data. Phew. Time for a simple table; create table Docs ( id uniqueidentifier rowguidcol not null primary key , documentData varbinary( max ) filestream not null , documentName nvarchar(1024) not null ) Now I've got a table I can use something like Windows Presentation...
    Filed under: , , , ,
  • Added (Updated) ADO.NET Data Services Videos to C9

    I produced a new set of short videos around ADO.NET Data Services and dropped them on to Channel 9. You can find them here; http://channel9.msdn.com/tags/UK and that list will grow as time goes in ( specifically, it'll grow if I can get the publishing system to publish my next 4 videos for me as it's not playing ball at the time of writing :-) ).
  • On Entity Framework, Concurrency

    This is similar but not at all identical to this post about LINQ to SQL because it's using a different framework and that has different capabilities. Someone mailed and asked how we can detect concurrency problems with Entity Framework in order to ensure that when we submit changes to the DB we first; Present the user with a list of all the concurrency errors in one go Present the user with their changes versus the DB's current data Ask the user how to go about resolving each issue Repeat until all the changes get to the DB one way or another I can use the same tables and scripts and so on that I used in the previous post about LINQ to SQL. So...if I've got this table in my DB; create table Person ( id int identity primary key , firstName nvarchar(30), lastName nvarchar(30), timestamp ) with data; insert person(firstname,lastname) values ( 'first1' , 'last1' ) insert person(firstname,lastname) values ( 'first2' , 'last2' ) insert person(firstname,lastname) values ( 'first3' , 'last3' ) and I bring this into an...
  • On LINQ to SQL, Concurrency and Timestamps

    I came across a bit of a glitch in using timestamps for checking concurrency violations in LINQ to SQL and thought I'd share. Say I've got a table like; create table Person ( id int identity primary key , firstName nvarchar(30), lastName nvarchar(30), timestamp ) so, we have a simple table that has a timestamp on it and I want to use that to detect any concurrency problems that I might have in LINQ to SQL. Let's populate this table with some data; insert person(firstname,lastname) values( 'first1' , 'last1' ) insert person(firstname,lastname) values( 'first2' , 'last2' ) insert person(firstname,lastname) values( 'first3' , 'last3' ) and then I can bring that into my LINQ to SQL environment and I can check what the concurrency options are set to; So, you can see that we've got Update Check set to Always and that means that the timestamp will be added to any where clauses for Deletes or Updates and if a particular update doesn't find any row to update because of that where clause then we have a concurrency violation...
  • Silverlight and ADO.NET Data Services ( 2 )

    Following on from this last post , if I start to edit the data in the grid and change some value then the property value will change in the underlying class but nothing else will happen. That is, the NorthwindEntities class which is managing my data for me client-side ( which is derived from DataServiceContext ) isn't going to be aware of those modifications. Why not? If we have a look at a property on a generated class such as this one for the CompanyName on the Customers class; public string CompanyName { get { return this ._CompanyName; } set { this .OnCompanyNameChanging( value ); this ._CompanyName = value ; this .OnCompanyNameChanged(); } } Now, OnCompanyNameChanging and OnCompanyNameChanged are partial methods with no implementation by default so nothing's going to happen when something like the DataGrid changes a value such as CompanyName. Similarly, the generated entity classes such as Customers do not implement INotifyPropertyChanged which means that changes in the data will not be reflected in the UI...
  • Silverlight and ADO.NET Data Services

    Someone mailed me to ask whether I had a video on how to put together Silverlight and ADO.NET Data Services. I don't at the time of writing and I've also got a cold right now ( thank you, Microsoft Manchester office :-) ) so I thought I'd write something rather than record it. Let's run through a step-by-step thing. Visual Studio 2008 - File->New->Web Site. I'm going for the filesystem and C# as below; Now, to make it easy to work with ADO.NET Data Services, I'm going to add in an ADO.NET Entity Data Model for Northwind. That is ... Website->Add->New Item; I say "yes" to add it to my app_code folder, then select; and then I can go and add a new ADO.NET Data Service ( again via Website->Add New Item ); and then I can update my service code to read; public class Service : DataService<NorthwindEntities> { // This method is called only once to initialize service-wide policies. public static void InitializeService(IDataServiceConfiguration config) { config.SetEntitySetAccessRule( "*" , EntitySetRights...
  • Entity Framework - Timestamps and Concurrency

    Someone asked me today how you'd go about ensuring that timestamp columns in your database tables show up in your Entity Framework EDMX file with a Concurrency=Fixed attribute on them. That is - it's very likely that the timestamps are there on the table to enforce concurrency so why not default their Concurrency value to "Fixed" ? It's a good question but it's not something that the tooling does as far as I'm aware so I tried to have together some LINQ to XML code that would make an attempt at it. I don't claim that this is correct at all but it might be a starting point for this and similar, related pre-processing that you want to do on an EDMX file. static void Main( string [] args) { XElement edmxFile = XElement.Load(args[0]); XNamespace edmxNs = XNamespace.Get( "http://schemas.microsoft.com/ado/2007/06/edmx" ); XNamespace ssdlNs = XNamespace.Get( "http://schemas.microsoft.com/ado/2006/04/edm/ssdl" ); XNamespace mapNs = XNamespace.Get( "urn:schemas-microsoft-com:windows:storage:mapping:CS" ); XNamespace csdlNs...
  • ADO.NET Data Services - IUpdatable on LINQ to SQL

    I made an attempt at implementing IUpdatable on the current (i.e. VS 2008 Sp1 B1) bits of ADO.NET Data Services. I struggled a little bit with this. When you produce a data service you provide a class which is derived from; DataService<T> and T might be your own custom type or it's more likely to be a class derived from DataContext ( LINQ to SQL ) or ObjectContext ( LINQ to Entities ). The framework reflects over the type that you provide as T in order to find public properties of type IQueryable<> and it can expose those ( if you tell it to ) as entity sets available over your service. If T is not an ObjectContext then the framework also looks to T to implement IUpdatable if you want to do read/write access to your data. It's extremely likely that if you're working with LINQ to SQL or LINQ to Entities then your type T will be the type that is generated from the tooling for you because that type already comes pre-populated with lots of IQueryable<> public properties nicely generated for you which...
  • ADO.NET Data Services and LINQ to SQL - Errors Generating Proxy Code with DataSvcUtil.exe

    Something that I came across today - if you're trying to surface a LINQ to SQL data source via the latest build of ADO.NET Data Services and you're running datasvcutil.exe on the metadata of the service then you might find yourself with a whole bunch of errors. Here's a sample of what I was getting this morning; error 7001: Schema specified is not valid. Errors: $metadata(0,0) : error 0005: The 'Namespace' attribute is invalid - The value '' is invalid according to its datatype ' http://schemas.microsoft.com/ado/2006/04/ edm:TNamespaceName' - The Pattern constraint failed. For me, I resolved this by just making sure that I revisited my DBML diagram for LINQ to SQL in Visual Studio and set the "Entity Namespace" property for code generation. That is, click on the white-space of the diagram; to make sure that you have the diagram rather than a particular entity set selected. Then hit F4 for the properties; and give yourself a namespace and all the errors seem to go away reasonably quickly :-)
  • Authorising with ADO.NET Data Services

    Once we've got a request authenticated the next thing we might want to consider is authorising those requests as they make access to data. In researching this post I found that I'd actually written about this before but hadn't been quite as complete as I'd like to be ( and, to be honest, with my 5-minute memory I'd forgotten that I'd written it ) so these posts; ADO.NET Data Services & Authentication - Basic Auth in IIS 7 ADO.NET Data Services - More Sketchy Thoughts on Access Control ADO.NET Data Services - Sketchy Thoughts on Controlling Access just become "backgrounders" for this post with the caveat that they are now a little out of date as Data Services has moved on. With Data Services we have the possibility to make a bunch of entity sets available to a client and often I use the Northwind database as my example which would mean that if I was just exposing its raw schema I would see something like; Customers, Orders, Products, Shippers, etc. and we also have the opportunity to expose service operations...
  • ADO.NET Data Services - Concurrency in Action

    Just like for batching, there's a great explanation of how concurrency looks in ADO.NET Data Services up here so this is just a basic example. If I take the "Hello World" style service that I built back here then it does nothing about concurrency checking because, by default, when you build an entity data model with the Entity Framework tooling all of the concurrency options are set to "off". So, if I make a request for a customer and trace it with Fiddler then I see; You can see that I'm requesting the ALFKI customer and I'm just doing it from a browser as it happens. Now, if I go and alter my entity data model a little bit to say that ( purely for instance ) I want to have concurrency checking done on the PostalCode, Country, Region, Address fields of the Customers entity type as in; Then the next time I request that entity I see an ETag header being emitted that contains the value of my concurrency token; and if I was to request lots of customers then I'd see these ETags move into the response data as in; From...
  • ADO.NET Data Services - Batching in Action

    I did a talk on Data Services at DevDays, Amsterdam last week and so I had to take a rather speedy look at batching support as that had been added to the VS 2008 Sp1 bits since the previous preview. Batching is explained up here but here's just a little example of using it. If we take "hello world" style service that we created back in this post and we were to do something like this from the .NET client side code; static void Main( string [] args) { Console.ReadLine(); NorthwindEntities proxy = new NorthwindEntities( new Uri( "https://localhost/SecureSite/Secure/Service.svc" )); foreach (Shippers s in proxy.Shippers) { Console.WriteLine(s.ShipperID); } foreach (Employees e in proxy.Employees) { Console.WriteLine(e.EmployeeID); } Console.ReadLine(); } and if we were to go ahead and trace that traffic with Fiddler then we'd see; That is - we see and HTTP GET request for Shippers and then another one for Employees. Now, if these 2 entity sets are related then we can use the $expand query string operator in order...
1 2 3 4 5 Next >