c#-4.0

How to select current dates from current month

非 Y 不嫁゛ 提交于 2020-01-15 03:32:06
问题 I would like to retrieve the data between 1 -30 of the current month [ i am using MSACCESS Dbase to do so] Below is the query that i am trying -- SELECT count(usercategory) as category_count ,usercategory FROM user_category where IssueDate between DATEADD('m', DATEDIFF('m', 0, DATE()) - 0 , 0) and DATEADD('m', DATEDIFF('m', 0, DATE()) + 1, - 1 ) group by usercategory Data that i am holding in my MSACCESS Dbase - Category1 9/7/2013 12:00:00 AM Category1 9/8/2013 12:00:00 AM Category2 10/8/2013

Most efficient way to read XML in ADO.net from XML type column in SQL server?

我只是一个虾纸丫 提交于 2020-01-14 14:52:06
问题 With a XML type column in SQL server, what is the most efficient way to read this back into an XmlDocument in ADO.Net? For this particular use, an XmlDocument is needed for random-access to the loaded document. Using .Net 4.0 (C#) and SQL Server 2008 R2. Originally, we had a stored procedure that was returning a result set. When calling SqlDataAdapter.Fill(DataTable) to obtain the results, the XML is returned only as a string . I then changed this to have the T-SQL return an output parameter

Why would an integer property sometimes return a 0?

a 夏天 提交于 2020-01-14 09:22:06
问题 [Edit: I realized that the parameter that is failing is actually a double and not an integer. None of the integer timers fail according to the logs. Most of the timers and parameters are integers, but not all. Doubles are not atomic and the lack of locking may be the issue after all.] I have an application that uses a class that contains properties for configurable values. Most of the properties being used in the app are derived. The values are set at start up and not changed while the main

Connection Pooling with Access database

耗尽温柔 提交于 2020-01-14 09:07:07
问题 I have an application which reads data from an Access databse frequently, is there any way to use connection pooling? My Open Databse method:- private bool OpenDatabaseConnection(string databaseName) { try { string connectionString = "Provider = Microsoft.Jet.OLEDB.4.0; " + "Data Source = " + databaseName + ";"; settingsDbConn = new OleDbConnection(connectionString); settingsDbConn.Open(); } catch (Exception) { return false; } return true; } 回答1: I concur with the comment of @sll but, to

Find and Replace text in XML file using c#

十年热恋 提交于 2020-01-14 09:04:12
问题 I am trying to find and replace text in an xml file using c#. What I want is to change server name in the url link throughout the file. http://Server1.extranet.abc/server1webdev/rest/services/ABC/ABC_Base/MapServer to http://Server2.extranet.abc/server1webdev/rest/services/ABC/ABC_Base/MapServer I tried using System.xml.linq (XDocument.load(xmlpath)) but it simply gives me the whole xml file as one line of string. Is there a way I can replace the text?Note that the url's are not in specific

Is there any tools to help me refactor a method call from using position-based to name-based parameters

混江龙づ霸主 提交于 2020-01-14 07:55:08
问题 I wish to transform code like: var p = new Person("Ian", "Smith", 40, 16) To: var p = new Person(surname: "Ian", givenName:"Smith", weight:40, age:16) As a first step in making the code more readable, I am willing to use a 3rd party refactoring tool if need be. (Please do not tell me to use parameter objects and factor methods etc, these may come later once I can at least read the code!) 回答1: Refactor v2001 vol 1.3 claims to be able to do it. ReSharper has it in it's issues database, but have

XAML Binding to the opposite of another element

孤人 提交于 2020-01-14 07:24:12
问题 I am developing a simple exercise and want to know if there is a way to bind to the opposite of another element using only XAML. For example. I have two buttons on a form, Start and Stop perhaps for a timer. I dont want both to be enables at the same time. When the program starts, the stop button should be disabled. When the start button is clicked, it should be disabled and the stop button enabled. Then vice versa until the user quits. I know there are better controls for exactly this, and I

Can I define an abstract class for all derived Singletons in this way?

三世轮回 提交于 2020-01-14 07:06:07
问题 This is my abstract class which must be derived each time I want to make a Singleton: public abstract class Singleton<T> where T : Singleton<T> { private static readonly Lazy<T> _instance = new Lazy<T>(() => { var constructor = typeof(T).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[0], null); return (T)constructor.Invoke(null); }); public static T Instance { get { return _instance.Value; } } public Singleton() { } } So, every time I need to follow the

Model object passed to HttpPost action is having null values

匆匆过客 提交于 2020-01-14 06:05:09
问题 I have a model with properties declared, Controller actions. and View with Viewmodel specified. I fill data in the form and submit, but model has only null values for all properties. If i try with view model i get same null values in HttpPost action. My Model: public class Supplier { public string SupplierSequenceNumber { get; set; } public string SupplierName { get; set; } public string SupplierActive { get; set; } } My Controller: [HttpGet] public ActionResult Add() { SupplierVM

Get N max numbers and their corresponding position(index) from a 2D array double[,] using lambda expression

倖福魔咒の 提交于 2020-01-14 04:05:04
问题 This is a question similar to [ Get N max numbers from a List<int> using lambda expression ] But I want to learn if I want to keep the index of those N max numbers, how should I write it using lambda expression. Example) List<int> numbers = new List<int> { 12, 5, -8, 4, 7, 28, 3, 22 }; How can we get 4 maximum numbers by lambda: {28, 22, 12, 7} plus indexes { 5, 7, 0, 4} as kirill suggested: var result = numbers.OrderByDescending(n => n).Take(4); but how can I get the index of those N max