c#

Programmatically open a file in Visual Studio (2010)

余生长醉 提交于 2021-02-20 08:32:12
问题 I'm building a VS package, and I'm trying to send a command from the package to Visual Studio to open up a user selected file in a new tab (just like a user would do it by going to File -> Open...). I remember seeing at some point how to do this. Can anybody refresh my memory? 回答1: I believe you want one of: IVsUIShellOpenDocument.OpenStandardEditor DTE.OpenFile DTE.ItemOperations.OpenFile In the end, I think they all boil down to the same behavior. 回答2: I like to use the DTE method

Types don't match for creating a CLR Stored Procedure

丶灬走出姿态 提交于 2021-02-20 07:02:58
问题 I have a method in an assembly that looks like this: namespace MyNameSpace { public class MyClass { [Microsoft.SqlServer.Server.SqlProcedure] public static void MyMethod(SqlChars myMessage) { // Stuff here } } } I compile that to a dll and load it into my SQL Server like this: drop assembly MyAssembly create assembly MyAssemblyfrom 'C:\Scripts\MyAssembly.dll' That all works fine. But now I try to run this: CREATE PROCEDURE MySproc @message nvarchar(max) AS EXTERNAL NAME MyAssembly.

async Indexer in C#

淺唱寂寞╮ 提交于 2021-02-20 07:01:56
问题 Recently, we have movied to EF 6 and we have begun to use EF async commands. For example in my repository I have the following method: // Gets entities asynchron in a range starting from skip. // Take defines the maximum number of entities to be returned. public async Task<IEnumerable<TEntity>> GetRangeAsync(int skip, int take) { var entities = this.AddIncludes(this.DbContext.Set<TEntity>()) .OrderBy(this.SortSpec.PropertyName) .Skip(skip) .Take(take) .ToListAsync(); return await entities; }

Getting property attributes in TagHelpers

試著忘記壹切 提交于 2021-02-20 06:50:14
问题 Some of model properties has "Required" data annotation, that I need to read in a TagHelper class. public partial class Sale { [Required] public string CustomerId { get; set; } ... In the sales view I create a custom select for customer: <customer asp-for="CustomerId " value="@Model.CustomerId"></customer> And in the CustomerTagHelper class there is the process method: public override void Process(TagHelperContext context, TagHelperOutput output) { How can I discover at this point, if the

Actions require unique method/path combination for Swagger

有些话、适合烂在心里 提交于 2021-02-20 06:32:03
问题 I have 2 HTTP GET method in same controller and give me this error HTTP method "GET" & path "api/DataStore" overloaded by actions - DPK.HostApi.Controllers.DataStoreController.GetByIdAsync (DPK.HostApi),DPK.HostApi.Controllers.DataStoreController.GetAllAsync (DPK.HostApi). Actions require unique method/path combination for Swagger 2.0. My Controller : [Route("api/[controller]")] [ApiController] public class DataStoreController : ApiControllerBase { private readonly IDataStoreService

How should I convert a function returning a non-generic Task to ValueTask?

杀马特。学长 韩版系。学妹 提交于 2021-02-20 06:30:52
问题 I'm working on some code which builds a buffer in memory and then empties it into a TextWriter when the buffer fills up. Most of the time, the character will go straight into the buffer (synchronously) but occasionally (once every 4kb) I need to call TextWriter.WriteAsync . In the System.Threading.Tasks.Extensions package there only appears to be a ValueTask<T> struct, and no non-generic ValueTask (without a type parameter). Why is there no ValueTask , and what should I do if I need to

Actions require unique method/path combination for Swagger

和自甴很熟 提交于 2021-02-20 06:30:24
问题 I have 2 HTTP GET method in same controller and give me this error HTTP method "GET" & path "api/DataStore" overloaded by actions - DPK.HostApi.Controllers.DataStoreController.GetByIdAsync (DPK.HostApi),DPK.HostApi.Controllers.DataStoreController.GetAllAsync (DPK.HostApi). Actions require unique method/path combination for Swagger 2.0. My Controller : [Route("api/[controller]")] [ApiController] public class DataStoreController : ApiControllerBase { private readonly IDataStoreService

How should I convert a function returning a non-generic Task to ValueTask?

社会主义新天地 提交于 2021-02-20 06:28:50
问题 I'm working on some code which builds a buffer in memory and then empties it into a TextWriter when the buffer fills up. Most of the time, the character will go straight into the buffer (synchronously) but occasionally (once every 4kb) I need to call TextWriter.WriteAsync . In the System.Threading.Tasks.Extensions package there only appears to be a ValueTask<T> struct, and no non-generic ValueTask (without a type parameter). Why is there no ValueTask , and what should I do if I need to

one of the parameters of a binary operator must be the containing type c#

怎甘沉沦 提交于 2021-02-20 06:25:50
问题 public static int[,] operator *(int[,] arr1, int[,] arr2) { int sum; int[,] res = new int[arr1.GetLength(0), arr2.GetLength(1)]; for (int i = 0; i < arr1.GetLength(0); i++) { for (int j = 0; j < arr2.GetLength(1); j++) { sum = 0; for (int k = 0; k < arr1.GetLength(1); k++) { sum = sum + (arr1[i, k] * arr2[k, j]); } res[i, j] = sum; //Console.Write("{0} ", res[i, j]); } //Console.WriteLine(); } return res; } Here i am trying to overload * operator to multiply two matrices.. but the compiler

one of the parameters of a binary operator must be the containing type c#

≡放荡痞女 提交于 2021-02-20 06:19:52
问题 public static int[,] operator *(int[,] arr1, int[,] arr2) { int sum; int[,] res = new int[arr1.GetLength(0), arr2.GetLength(1)]; for (int i = 0; i < arr1.GetLength(0); i++) { for (int j = 0; j < arr2.GetLength(1); j++) { sum = 0; for (int k = 0; k < arr1.GetLength(1); k++) { sum = sum + (arr1[i, k] * arr2[k, j]); } res[i, j] = sum; //Console.Write("{0} ", res[i, j]); } //Console.WriteLine(); } return res; } Here i am trying to overload * operator to multiply two matrices.. but the compiler