From de85aeac884b1fe2749b38617ebf3057fc7b36f6 Mon Sep 17 00:00:00 2001 From: Maira Wenzel Date: Wed, 4 Apr 2018 04:39:16 -0700 Subject: [PATCH 1/7] update author (#4869) --- .../get-started/get-started-with-visual-studio-for-mac.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/docs/fsharp/get-started/get-started-with-visual-studio-for-mac.md b/docs/fsharp/get-started/get-started-with-visual-studio-for-mac.md index 08e5fa1c52184..c5e9af4acba2f 100644 --- a/docs/fsharp/get-started/get-started-with-visual-studio-for-mac.md +++ b/docs/fsharp/get-started/get-started-with-visual-studio-for-mac.md @@ -1,17 +1,14 @@ --- title: Get started with F# in Visual Studio for Mac description: Learn how to use F# with Visual Studio for Mac. -keywords: visual f#, f#, functional programming -author: mizzle-mo +author: cartermp ms.author: phcart ms.date: 02/13/2017 ms.topic: article ms.prod: .net ms.technology: devlang-fsharp ms.devlang: fsharp -ms.assetid: 8db75596-19a9-4eda-b20d-a12d517c8cc1 --- - # Get started with F# in Visual Studio for Mac F# and the Visual F# tooling are supported in the Visual Studio for Mac IDE. To begin, you should [download Visual Studio for Mac](https://aka.ms/vsdownload?utm_source=mscom&utm_campaign=msdocs), if you haven't already. This article uses the Visual Studio Community 2017 for Mac, but you can use F# with the version of your choice. From 635e1986db6110e9f7befdca5362157f1fd00bda Mon Sep 17 00:00:00 2001 From: Petr Kulikov Date: Wed, 4 Apr 2018 16:19:20 +0200 Subject: [PATCH 2/7] null-conditional-operators.md: review (#4850) * null-conditional-operators.md: review * Fixed the second example description * Removed unnecessary explanations * Updated the short-circuiting example. --- .../operators/null-conditional-operators.md | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/docs/csharp/language-reference/operators/null-conditional-operators.md b/docs/csharp/language-reference/operators/null-conditional-operators.md index aa98f0c6575f2..993c9b3853648 100644 --- a/docs/csharp/language-reference/operators/null-conditional-operators.md +++ b/docs/csharp/language-reference/operators/null-conditional-operators.md @@ -1,17 +1,27 @@ --- title: "Null-conditional Operators (C# and Visual Basic)" -ms.date: 07/20/2015 +ms.date: 04/03/2015 ms.prod: .net ms.technology: - "devlang-csharp" ms.topic: "article" +dev_langs: + - "csharp" + - "vb" +helpviewer_keywords: + - "null-conditional operators [C#]" + - "null-conditional operators [Visual Basic]" + - "?. operator [C#]" + - "?. operator [Visual Basic]" + - "?[] operator [C#]" + - "?[] operator [Visual Basic]" ms.assetid: 9c7b2c8f-a785-44ca-836c-407bfb6d27f5 caps.latest.revision: 3 author: "BillWagner" ms.author: "wiwagn" --- -# Null-conditional Operators (C# and Visual Basic) -Used to test for null before performing a member access (`?.`) or index (`?[`) operation. These operators help you write less code to handle null checks, especially for descending into data structures. +# ?. and ?[] null-conditional Operators (C# and Visual Basic) +Used to test for null before performing a member access (`?.`) or index (`?[]`) operation. These operators help you write less code to handle null checks, especially for descending into data structures. ```csharp int? length = customers?.Length; // null if customers is null @@ -25,16 +35,16 @@ Dim first as Customer = customers?(0) ' null if customers is null Dim count as Integer? = customers?(0)?.Orders?.Count() ' null if customers, the first customer, or Orders is null ``` - The last example demonstrates that the null-condition operators are short-circuiting. If one operation in a chain of conditional member access and index operation returns null, then the rest of the chain’s execution stops. Other operations with lower precedence in the expression continue. For example, `E` in the following executes in the second line, and the `??` and `==` operations execute. In the first line, the `??` short circuits and `E` does not execute when the left side evaluates to non-null. + The null-condition operators are short-circuiting. If one operation in a chain of conditional member access and index operation returns null, then the rest of the chain’s execution stops. In the following example, `E` doesn't execute if `A`, `B`, or `C` evaluates to null. ```csharp -A?.B?.C?[0] ?? E -A?.B?.C?[0] == E +A?.B?.C?.Do(E); +A?.B?.C?[E]; ``` ```vb -A?.B?.C?(0) ?? E -A?.B?.C?(0) == E +A?.B?.C?.Do(E); +A?.B?.C?(E); ``` Another use for the null-condition member access is invoking delegates in a thread-safe way with much less code. The old way requires code like the following: @@ -63,7 +73,7 @@ PropertyChanged?.Invoke(e) The new way is thread-safe because the compiler generates code to evaluate `PropertyChanged` one time only, keeping the result in a temporary variable. - You need to explicitly call the `Invoke` method because there is no null-conditional delegate invocation syntax `PropertyChanged?(e)`. There were too many ambiguous parsing situations to allow it. + You need to explicitly call the `Invoke` method because there is no null-conditional delegate invocation syntax `PropertyChanged?(e)`. ## Language Specifications [!INCLUDE[CSharplangspec](~/includes/csharplangspec-md.md)] From 44d68f0561579383c3fe9febc725e851b036dc08 Mon Sep 17 00:00:00 2001 From: Scott Addie Date: Wed, 4 Apr 2018 12:21:32 -0400 Subject: [PATCH 3/7] Add link to RIDs doc (#4872) Fixes https://github.com/dotnet/docs/issues/4871 --- docs/core/tools/dotnet-store.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core/tools/dotnet-store.md b/docs/core/tools/dotnet-store.md index cfaf53b5ff261..8fc2b9d855b56 100644 --- a/docs/core/tools/dotnet-store.md +++ b/docs/core/tools/dotnet-store.md @@ -38,7 +38,7 @@ The *package store manifest file* is an XML file that contains the list of packa `-r|--runtime ` -The runtime identifier to target. +The [runtime identifier](../rid-catalog.md) to target. ## Optional options From 5f3393dfc519f0c61eba07f7f3a14f15f669e282 Mon Sep 17 00:00:00 2001 From: Scott Addie Date: Wed, 4 Apr 2018 12:24:47 -0400 Subject: [PATCH 4/7] Mention the RuntimeIdentifiers element to support multiple RIDs (#4874) Fixes https://github.com/dotnet/docs/issues/4873 --- docs/core/rid-catalog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core/rid-catalog.md b/docs/core/rid-catalog.md index a8a9310a61750..8354185dd8051 100644 --- a/docs/core/rid-catalog.md +++ b/docs/core/rid-catalog.md @@ -15,7 +15,7 @@ RID is short for *Runtime IDentifier*. RID values are used to identify target pl They're used by .NET packages to represent platform-specific assets in NuGet packages. The following values are examples of RIDs: `linux-x64`, `ubuntu.14.04-x64`, `win7-x64`, or `osx.10.12-x64`. For the packages with native dependencies, the RID designates on which platforms the package can be restored. -RIDs can be set in the `` element of your project file. They're also used via the `--runtime` option with the following [.NET Core CLI commands](./tools/index.md): +A single RID can be set in the `` element of your project file. Multiple RIDs can be defined as a semicolon-delimited list in the project file's `` element. They're also used via the `--runtime` option with the following [.NET Core CLI commands](./tools/index.md): - [dotnet build](./tools/dotnet-build.md) - [dotnet clean](./tools/dotnet-clean.md) From cf1da2a90920e9165e974f129034a80cfcf0421b Mon Sep 17 00:00:00 2001 From: Douglas Laudenschlager Date: Wed, 4 Apr 2018 09:25:46 -0700 Subject: [PATCH 5/7] Clarified Azure login requirements per VSTS 1202392. (#4865) --- .../data/adonet/connection-string-syntax.md | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/docs/framework/data/adonet/connection-string-syntax.md b/docs/framework/data/adonet/connection-string-syntax.md index faac2d0214b68..367bf985310d2 100644 --- a/docs/framework/data/adonet/connection-string-syntax.md +++ b/docs/framework/data/adonet/connection-string-syntax.md @@ -39,7 +39,7 @@ Each .NET Framework data provider has a `Connection` object that inherits from < - The connection string builders allow you to construct syntactically valid connection strings at run time, so you do not have to manually concatenate connection string values in your code. For more information, see [Connection String Builders](../../../../docs/framework/data/adonet/connection-string-builders.md). - + ## Windows Authentication We recommend using Windows Authentication (sometimes referred to as *integrated security*) to connect to data sources that support it. The syntax employed in the connection string varies by provider. The following table shows the Windows Authentication syntax used with the .NET Framework data providers. @@ -54,9 +54,13 @@ Each .NET Framework data provider has a `Connection` object that inherits from < > `Integrated Security=true` throws an exception when used with the `OleDb` provider. ## SqlClient Connection Strings - The syntax for a connection string is documented in the property. You can use the property to get or set a connection string for a SQL Server database. If you need to connect to an earlier version of SQL Server, you must use the .NET Framework Data Provider for OleDb (). Most connection string keywords also map to properties in the . - - Each of the following forms of syntax will use Windows Authentication to connect to the **AdventureWorks** database on a local server. +The syntax for a connection string is documented in the property. You can use the property to get or set a connection string for a SQL Server database. If you need to connect to an earlier version of SQL Server, you must use the .NET Framework Data Provider for OleDb (). Most connection string keywords also map to properties in the . + +> [!IMPORTANT] +> The default setting for the `Persist Security Info` keyword is `false`. Setting it to `true` or `yes` allows security-sensitive information, including the user ID and password, to be obtained from the connection after the connection has been opened. Keep `Persist Security Info` set to `false` to ensure that an untrusted source does not have access to sensitive connection string information. + +### Windows authentication with SqlClient + Each of the following forms of syntax uses Windows Authentication to connect to the **AdventureWorks** database on a local server. ``` "Persist Security Info=False;Integrated Security=true; @@ -67,26 +71,26 @@ Each .NET Framework data provider has a `Connection` object that inherits from < database=AdventureWorks;server=(local)" ``` -### SQL Server Logins +### SQL Server authentication with SqlClient Windows Authentication is preferred for connecting to SQL Server. However, if SQL Server Authentication is required, use the following syntax to specify a user name and password. In this example, asterisks are used to represent a valid user name and password. ``` "Persist Security Info=False;User ID=*****;Password=*****;Initial Catalog=AdventureWorks;Server=MySqlServer" ``` - -> [!IMPORTANT] -> The default setting for the `Persist Security Info` keyword is `false`. Setting it to `true` or `yes` allows security-sensitive information, including the user ID and password, to be obtained from the connection after the connection has been opened. Keep `Persist Security Info` set to `false` to ensure that an untrusted source does not have access to sensitive connection string information. - - To connect to a named instance of SQL Server, use the *server name\instance name* syntax. + +When you connect to Azure SQL Database or to Azure SQL Data Warehouse and provide a login in the format `user@servername`, make sure that the `servername` value in the login matches the value provided for `Server=`. + +> [!NOTE] +> Windows authentication takes precedence over SQL Server logins. If you specify both Integrated Security=true as well as a user name and password, the user name and password will be ignored and Windows authentication will be used. + +### Connect to a named instance of SQL Server +To connect to a named instance of SQL Server, use the *server name\instance name* syntax. ``` Data Source=MySqlServer\MSSQL1;" ``` - - You can also set the property of the `SqlConnectionStringBuilder` to the instance name when building a connection string. The property of a object is read-only. - -> [!NOTE] -> Windows authentication takes precedence over SQL Server logins. If you specify both Integrated Security=true as well as a user name and password, the user name and password will be ignored and Windows authentication will be used. + +You can also set the property of the `SqlConnectionStringBuilder` to the instance name when building a connection string. The property of a object is read-only. ### Type System Version Changes The `Type System Version` keyword in a specifies the client-side representation of [!INCLUDE[ssNoVersion](../../../../includes/ssnoversion-md.md)] types. See for more information about the `Type System Version` keyword. From a2c518b1abd551f3d6ba13545e3b5cf7d40bff45 Mon Sep 17 00:00:00 2001 From: Ron Petrusha Date: Wed, 4 Apr 2018 13:36:08 -0700 Subject: [PATCH 6/7] Fixed some broken links (#4864) * Fixed some broken links * Fixed additional bad links. --- .../generics/generics-and-reflection.md | 8 +-- .../reflection-and-generic-types.md | 8 +-- ...arranging-windows-forms-controls-in-wpf.md | 59 ++++++------------- 3 files changed, 25 insertions(+), 50 deletions(-) diff --git a/docs/csharp/programming-guide/generics/generics-and-reflection.md b/docs/csharp/programming-guide/generics/generics-and-reflection.md index 4a964f97346da..d414eb6821c2f 100644 --- a/docs/csharp/programming-guide/generics/generics-and-reflection.md +++ b/docs/csharp/programming-guide/generics/generics-and-reflection.md @@ -34,15 +34,15 @@ Because the Common Language Runtime (CLR) has access to generic type information ||Returns the generic method that defined the current generic type parameter, or null if the type parameter was not defined by a generic method.| ||Substitutes the elements of an array of types for the type parameters of the current generic type definition, and returns a object representing the resulting constructed type.| - In addition, new members are added to the class to enable run-time information for generic methods. See the property remarks for a list of invariant conditions for terms used to reflect on generic methods. + In addition, members of the class enable run-time information for generic methods. See the property remarks for a list of invariant conditions for terms used to reflect on generic methods. |System.Reflection.MemberInfo Member Name|Description| |----------------------------------------------|-----------------| -||Returns true if a method is generic.| +||Returns true if a method is generic.| ||Returns an array of Type objects that represent the type arguments of a constructed generic method or the type parameters of a generic method definition.| ||Returns the underlying generic method definition for the current constructed method.| -||Returns true if the method or any of its enclosing types contain any type parameters for which specific types have not been supplied.| -||Returns true if the current represents the definition of a generic method.| +||Returns true if the method or any of its enclosing types contain any type parameters for which specific types have not been supplied.| +||Returns true if the current represents the definition of a generic method.| ||Substitutes the elements of an array of types for the type parameters of the current generic method definition, and returns a object representing the resulting constructed method.| ## See Also diff --git a/docs/framework/reflection-and-codedom/reflection-and-generic-types.md b/docs/framework/reflection-and-codedom/reflection-and-generic-types.md index 1980296595870..450c3649f34a8 100644 --- a/docs/framework/reflection-and-codedom/reflection-and-generic-types.md +++ b/docs/framework/reflection-and-codedom/reflection-and-generic-types.md @@ -62,15 +62,15 @@ ms.workload: ## Is This a Generic Type or Method? - When you use reflection to examine an unknown type, represented by an instance of , use the property to determine whether the unknown type is generic. It returns `true` if the type is generic. Similarly, when you examine an unknown method, represented by an instance of the class, use the property to determine whether the method is generic. + When you use reflection to examine an unknown type, represented by an instance of , use the property to determine whether the unknown type is generic. It returns `true` if the type is generic. Similarly, when you examine an unknown method, represented by an instance of the class, use the property to determine whether the method is generic. ### Is This a Generic Type or Method Definition? - Use the property to determine whether a object represents a generic type definition, and use the method to determine whether a represents a generic method definition. + Use the property to determine whether a object represents a generic type definition, and use the method to determine whether a represents a generic method definition. Generic type and method definitions are the templates from which instantiable types are created. Generic types in the .NET Framework class library, such as , are generic type definitions. ### Is the Type or Method Open or Closed? - A generic type or method is closed if instantiable types have been substituted for all its type parameters, including all the type parameters of all enclosing types. You can only create an instance of a generic type if it is closed. The property returns `true` if a type is open. For methods, the method performs the same function. + A generic type or method is closed if instantiable types have been substituted for all its type parameters, including all the type parameters of all enclosing types. You can only create an instance of a generic type if it is closed. The property returns `true` if a type is open. For methods, the method performs the same function. [Back to top](#top) @@ -146,7 +146,7 @@ generic ref class D : B {}; ## Invariants - For a table of the invariant conditions for common terms in reflection for generic types, see . For additional terms relating to generic methods, see . + For a table of the invariant conditions for common terms in reflection for generic types, see . For additional terms relating to generic methods, see . [Back to top](#top) diff --git a/docs/framework/wpf/advanced/walkthrough-arranging-windows-forms-controls-in-wpf.md b/docs/framework/wpf/advanced/walkthrough-arranging-windows-forms-controls-in-wpf.md index 36a859d08f6a8..035ccfab22edc 100644 --- a/docs/framework/wpf/advanced/walkthrough-arranging-windows-forms-controls-in-wpf.md +++ b/docs/framework/wpf/advanced/walkthrough-arranging-windows-forms-controls-in-wpf.md @@ -1,13 +1,11 @@ --- title: "Walkthrough: Arranging Windows Forms Controls in WPF" ms.custom: "" -ms.date: "03/30/2017" +ms.date: "04/03/2018" ms.prod: ".net-framework" -ms.reviewer: "" ms.suite: "" ms.technology: - "dotnet-wpf" -ms.tgt_pltfrm: "" ms.topic: "article" dev_langs: - "csharp" @@ -16,7 +14,6 @@ helpviewer_keywords: - "hybrid applications [WPF interoperability]" - "arranging controls [WPF]" ms.assetid: a1db8049-15c7-45d6-ae3d-36a6735cb848 -caps.latest.revision: 31 author: dotnet-bot ms.author: dotnetcontent manager: "wpickett" @@ -158,24 +155,15 @@ This walkthrough shows you how to use [!INCLUDE[TLA2#tla_winclient](../../../../ 5. Click the **Click me** button. The `button1_Click` event handler sets the and properties on the hosted control. This causes the hosted control to be repositioned within the element. The host maintains the same screen area, but the hosted control is clipped. Instead, the hosted control should always fill the element. ## Understanding Z-Order Limitations - By default, visible elements are always drawn on top of other [!INCLUDE[TLA2#tla_winclient](../../../../includes/tla2sharptla-winclient-md.md)] elements, and they are unaffected by z-order. To enable z-ordering, set the property of the to true and the property to or . - -#### To see the default z-order behavior - -1. Copy the following XAML into the element. - + Visible elements are always drawn on top of other WPF elements, and they are unaffected by z-order. To see this z-order behavior, do the following: + +1. Copy the following XAML into the element. + [!code-xaml[WpfLayoutHostingWfWithXaml#8](../../../../samples/snippets/csharp/VS_Snippets_Wpf/WpfLayoutHostingWfWithXaml/CSharp/Window1.xaml#8)] - + 2. Press F5 to build and run the application. The element is painted over the label element. - -#### To see the z-order behavior when IsRedirected is true - -1. Replace the previous z-order example with the following XAML. - - [!code-xaml[WpfLayoutHostingWfWithXaml#8b](../../../../samples/snippets/visualbasic/VS_Snippets_Wpf/WpfLayoutHostingWfWithXaml/VisualBasic/Window1.xaml#8b)] - - Press F5 to build and run the application. The label element is painted over the element. - + + ## Docking element supports [!INCLUDE[TLA2#tla_winclient](../../../../includes/tla2sharptla-winclient-md.md)] docking. Set the attached property to dock the hosted control in a element. @@ -219,7 +207,7 @@ This walkthrough shows you how to use [!INCLUDE[TLA2#tla_winclient](../../../../ 2. Press F5 to build and run the application. The element is centered in the grid row, but it is not stretched to fill the available space. If the window is large enough, you may see two or more months displayed by the hosted control, but these are centered in the row. The [!INCLUDE[TLA2#tla_winclient](../../../../includes/tla2sharptla-winclient-md.md)] layout engine centers elements that cannot be sized to fill the available space. ## Scaling - Unlike [!INCLUDE[TLA2#tla_winclient](../../../../includes/tla2sharptla-winclient-md.md)] elements, most [!INCLUDE[TLA#tla_winforms](../../../../includes/tlasharptla-winforms-md.md)] controls are not continuously scalable. By default, the element scales its hosted control when possible. To enable full-fledged scaling, set the property of the to true and the property to or . + Unlike WPF elements, most Windows Forms controls are not continuously scalable. To provide custom scaling, you override the method. #### To scale a hosted control by using the default behavior @@ -227,19 +215,13 @@ This walkthrough shows you how to use [!INCLUDE[TLA2#tla_winclient](../../../../ [!code-xaml[WpfLayoutHostingWfWithXaml#12](../../../../samples/snippets/csharp/VS_Snippets_Wpf/WpfLayoutHostingWfWithXaml/CSharp/Window1.xaml#12)] -2. Press F5 to build and run the application. The hosted control and its surrounding elements are scaled by a factor of 0.5. However, the hosted control's font is not scaled. - -#### To scale a hosted control by setting IsRedirected to true - -1. Replace the previous scaling example with the following XAML. - - [!code-xaml[WpfLayoutHostingWfWithXaml#12b](../../../../samples/snippets/visualbasic/VS_Snippets_Wpf/WpfLayoutHostingWfWithXaml/VisualBasic/Window1.xaml#12b)] - -2. Press F5 to build and run the application. The hosted control, its surrounding elements, and the hosted control's font are scaled by a factor of 0.5. - +2. Press F5 to build and run the application. The hosted control and its surrounding elements are scaled by a factor of 0.5. However, the hosted control's font is not scaled. + + + ## Rotating - Unlike [!INCLUDE[TLA2#tla_winclient](../../../../includes/tla2sharptla-winclient-md.md)] elements, [!INCLUDE[TLA#tla_winforms](../../../../includes/tlasharptla-winforms-md.md)] controls do not support rotation. By default, the element does not rotate with other [!INCLUDE[TLA2#tla_winclient](../../../../includes/tla2sharptla-winclient-md.md)] elements when a rotation transformation is applied. Any rotation value other than 180 degrees raises the event. To enable rotating to any angle, set the property of the to true and the property to or . - + Unlike WPF elements, Windows Forms controls do not support rotation. The element does not rotate with other WPF elements when a rotation transformation is applied. Any rotation value other than 180 degrees raises the event. + #### To see the effect of rotation in a hybrid application 1. Copy the following XAML into the element. @@ -247,15 +229,8 @@ This walkthrough shows you how to use [!INCLUDE[TLA2#tla_winclient](../../../../ [!code-xaml[WpfLayoutHostingWfWithXaml#13](../../../../samples/snippets/csharp/VS_Snippets_Wpf/WpfLayoutHostingWfWithXaml/CSharp/Window1.xaml#13)] 2. Press F5 to build and run the application. The hosted control is not rotated, but its surrounding elements are rotated by an angle of 180 degrees. You may have to resize the window to see the elements. - -#### To see the effect of rotation in a hybrid application when IsRedirected is true - -1. Replace the previous rotation example with the following XAML. - - [!code-xaml[WpfLayoutHostingWfWithXaml#13b](../../../../samples/snippets/visualbasic/VS_Snippets_Wpf/WpfLayoutHostingWfWithXaml/VisualBasic/Window1.xaml#13b)] - -2. Press F5 to build and run the application. The hosted control is rotated. Note that the property can be set to any value. You may have to resize the window to see the elements. - + + ## Setting Padding and Margins Padding and margins in [!INCLUDE[TLA2#tla_winclient](../../../../includes/tla2sharptla-winclient-md.md)] layout are similar to padding and margins in [!INCLUDE[TLA#tla_winforms](../../../../includes/tlasharptla-winforms-md.md)]. Simply set the and properties on the element. From 830093de76b557cdf5eed7eb7e789584968506eb Mon Sep 17 00:00:00 2001 From: Keerat Singh Date: Wed, 4 Apr 2018 15:21:14 -0700 Subject: [PATCH 7/7] Remove unnecessary leftover code (#4879) The removed lines were unnecessary leftover code probably from a previous edit, and were causing compilation errors. Also, update FileAccess to ReadWrite as per the description before the code block. --- .../data/adonet/sql/filestream-data.md | 39 +------------------ 1 file changed, 2 insertions(+), 37 deletions(-) diff --git a/docs/framework/data/adonet/sql/filestream-data.md b/docs/framework/data/adonet/sql/filestream-data.md index 0d7be8888f094..e3f5dbf621415 100644 --- a/docs/framework/data/adonet/sql/filestream-data.md +++ b/docs/framework/data/adonet/sql/filestream-data.md @@ -157,7 +157,7 @@ namespace FileStreamTest string path = reader.GetString(0); byte[] transactionContext = reader.GetSqlBytes(1).Buffer; - using (Stream fileStream = new SqlFileStream(path, transactionContext, FileAccess.Write, FileOptions.SequentialScan, allocationSize: 0)) + using (Stream fileStream = new SqlFileStream(path, transactionContext, FileAccess.ReadWrite, FileOptions.SequentialScan, allocationSize: 0)) { // Seek to the end of the file fileStream.Seek(0, SeekOrigin.End); @@ -172,42 +172,7 @@ namespace FileStreamTest } } -} using (SqlConnection connection = new SqlConnection( - connStringBuilder.ToString())) -{ - connection.Open(); - - SqlCommand command = new SqlCommand("", connection); - command.CommandText = "select Top(1) Photo.PathName(), " - + "GET_FILESTREAM_TRANSACTION_CONTEXT () from employees"; - - SqlTransaction tran = connection.BeginTransaction( - System.Data.IsolationLevel.ReadCommitted); - command.Transaction = tran; - - using (SqlDataReader reader = command.ExecuteReader()) - { - while (reader.Read()) - { - // Get the pointer for file - string path = reader.GetString(0); - byte[] transactionContext = reader.GetSqlBytes(1).Buffer; - - FileStream fileStream = new SqlFileStream(path, - (byte[])reader.GetValue(1), - FileAccess.ReadWrite, - FileOptions.SequentialScan, 0); - - // Seek to the end of the file - fs.Seek(0, SeekOrigin.End); - - // Append a single byte - fileStream.WriteByte(0x01); - fileStream.Close(); - } - } - tran.Commit(); -} +} ``` For another sample, see [How to store and fetch binary data into a file stream column](http://www.codeproject.com/Articles/32216/How-to-store-and-fetch-binary-data-into-a-file-str).