.net

How to log SQL generated by EF using log4net

时光怂恿深爱的人放手 提交于 2021-02-07 09:19:21
问题 In my web project I'm using EF6 and I'd like to log generated SQL for debugging purpose. I'm also using log4net to handle logs, so I'm looking for a way to integrate them together. What's the correct way to achieve this? 回答1: At the moment I'm using this approach: in my BaseController I have something like this: public class BaseController { protected MyDbContext DataContext { get; set; } protected readonly ILog logger; public BaseController() { DataContext = new MyDbContext(); logger =

How to log SQL generated by EF using log4net

若如初见. 提交于 2021-02-07 09:17:00
问题 In my web project I'm using EF6 and I'd like to log generated SQL for debugging purpose. I'm also using log4net to handle logs, so I'm looking for a way to integrate them together. What's the correct way to achieve this? 回答1: At the moment I'm using this approach: in my BaseController I have something like this: public class BaseController { protected MyDbContext DataContext { get; set; } protected readonly ILog logger; public BaseController() { DataContext = new MyDbContext(); logger =

Access .NET generic objects from VBA

血红的双手。 提交于 2021-02-07 09:16:28
问题 My .net code has an object with a number of generic properties. This object is returned to the VBA code. All the non-generic properties are working well, but I also need to access the generic values. Is there a way to do it from VBA? [ClassInterface(ClassInterfaceType.AutoDual)] public class Obj { public string GetProp1() {...} public IList<MyCustomType> GetProp2() {...} } VB code: Sub Test() Dim o As Program.Obj Set o = New Program.Obj Set p2 = hp.GetProp2() set p2_0 = p2(0) ' doesn't work

Long running method in controller action - MVC [duplicate]

非 Y 不嫁゛ 提交于 2021-02-07 09:15:29
问题 This question already has answers here : Long running task in WebAPI (5 answers) Closed 6 years ago . I have a method similar to the following in WebAPI - MVC public IActionResult Post(Model model) { ALongRunningMethod(); return Ok(); } I have two options. Wait for the method to complete. But, what if its too long ? Doesn't the API timeout ? Run that in a separate thread using Tasks but return Ok (200 HTTP Code) immediately ? What if some exception occur in that long running method ? Totally

Access .NET generic objects from VBA

穿精又带淫゛_ 提交于 2021-02-07 09:14:09
问题 My .net code has an object with a number of generic properties. This object is returned to the VBA code. All the non-generic properties are working well, but I also need to access the generic values. Is there a way to do it from VBA? [ClassInterface(ClassInterfaceType.AutoDual)] public class Obj { public string GetProp1() {...} public IList<MyCustomType> GetProp2() {...} } VB code: Sub Test() Dim o As Program.Obj Set o = New Program.Obj Set p2 = hp.GetProp2() set p2_0 = p2(0) ' doesn't work

How to read values from a comma separated file?

依然范特西╮ 提交于 2021-02-07 09:11:23
问题 I want to read words in a text file of a line separated by commas in c sharp. For example, I want to read this line: 9/10/2011 10:05,995.4,998.8,995.4,997.5,118000 and get the values: 9/10/2011 10:05 , 995.4 , 998.8 , 995.4 , 997.5 and 118000 . Next, I also need to change the format of the date to MMddYYYY , and of the time to HHmmss (e.g. 100500 ). I am using this code for reading is there anything wrong private void button1_Click(object sender, EventArgs e) { StreamReader reader1 = File

How to read values from a comma separated file?

主宰稳场 提交于 2021-02-07 09:11:16
问题 I want to read words in a text file of a line separated by commas in c sharp. For example, I want to read this line: 9/10/2011 10:05,995.4,998.8,995.4,997.5,118000 and get the values: 9/10/2011 10:05 , 995.4 , 998.8 , 995.4 , 997.5 and 118000 . Next, I also need to change the format of the date to MMddYYYY , and of the time to HHmmss (e.g. 100500 ). I am using this code for reading is there anything wrong private void button1_Click(object sender, EventArgs e) { StreamReader reader1 = File

Getting WSDL from VS2010 WCF Service application

╄→гoц情女王★ 提交于 2021-02-07 08:57:16
问题 I Just created a sample WCF Service application in Visual Studio 2010. It has the following configuration and service code. I need to see the corresponding WSDL generated. What I need to do to see the corresponding WSDL? CODE public class Service1 : IService1 { public string GetData(int value) { return string.Format("You entered: {0}", value); } public CompositeType GetDataUsingDataContract(CompositeType composite) { if (composite == null) { throw new ArgumentNullException("composite"); } if

Getting WSDL from VS2010 WCF Service application

大兔子大兔子 提交于 2021-02-07 08:56:06
问题 I Just created a sample WCF Service application in Visual Studio 2010. It has the following configuration and service code. I need to see the corresponding WSDL generated. What I need to do to see the corresponding WSDL? CODE public class Service1 : IService1 { public string GetData(int value) { return string.Format("You entered: {0}", value); } public CompositeType GetDataUsingDataContract(CompositeType composite) { if (composite == null) { throw new ArgumentNullException("composite"); } if

LINQ performance - deferred v/s immediate execution

♀尐吖头ヾ 提交于 2021-02-07 08:56:03
问题 I have seen that sometimes the performance of LINQ to Objects queries can be improved significantly if they forced to execute immediately by using .ToArray() , but can't quite understand why. For example, in the sample below, the execution of the function Deferred() is much slower than the function Immediate() , and grows exponentially with the value of limit (perhaps it was exponential in both functions, but execution time with Immediate() was too little for me to say definitively). public