Bastien Vandamme

1

votes
1

answer
68

views

Convert Ruby hash to Json in C#

I'm looking for help to write a method to convert Ruby hash to Json in C#. FYI A Ruby hash is like this: {'tiger'=>3, 'lion'=>2, 'dog'=>2, 'cat'=>3} But can also contains array like this {'section'=>'Gar', 'code'=>2, 'collections'=>'[{:key=>\'emotion\', :value=>\'Emotion\'}]', 'batch'=>'M'} I know i...
Bastien Vandamme
1

votes
1

answer
131

views

How to implement optimistic concurrency lock with EF 6?

I have a question that mix SQL server, Entity Framework and Web API. I need to manage a serial number database. To do so I created a sequence table in my SQL server. I use EF6 code first. public class Sequence : ITrackingDate { [Key] public string Name { get; set; } public long CurrentValue { get; s...
Bastien Vandamme
1

votes
1

answer
32

views

What is correct route with OData v4?

I'm building a OData v4 service and I need help on my model and what can be done and cannot be done with OData. I'm using .NET Core 2.2 and Entity Framework Core and ASP.NET Core also. This is my first application with .NET Core. I have, at this moment this POST request [HttpPost] [ODataRoute('Event...
Bastien Vandamme
0

votes
0

answer
6

views

How to add “Content-Type = application/json;v=2.0” including versioning with HttpClient?

Sorry to ask this question like this. I can give you the feeling I would like you to do the code for me. I already spent a day tying to write the code to send a http request that contains a header with versioning: For versioning I use the versioning by Media Type from Microsoft/aspnet-api-versioning...
Bastien Vandamme
1

votes
1

answer
15

views

OData Containment

I just learn that with the [Contained] attribute I can define a contained collection. This means the collection is no more accessible from my root oData system. Ok fine, but here is my model: I have a user that have addresses The user has invoices Each invoice can have one or two addresses from the...
Bastien Vandamme
1

votes
1

answer
281

views

What is the difference between ConfigurationManager class and Settings class?

What is the difference between ConfigurationManager class and Settings class ? I would like to load settings from a configuration file placed in the same folder than my executable. What should I use? Thank you,
Bastien Vandamme
1

votes
3

answer
221

views

In MVC, MVP and MVVM the model could it be a collection of entities?

I try to understand what a Model is. I already read this answer. In MVC, MVP and MVVM the model could it be a collection of entities?
Bastien Vandamme
1

votes
2

answer
217

views

How call a general method with data binding?

I would like to understand how to correctly use MVVM and data binding when we are working with many properties. I have a OriginalText TextBox and a ModifiedText Label. When I check a box I would like to directly apply the modification without having to click a button. How should I do that? In my Vie...
1

votes
2

answer
4.5k

views

How can create a dynamic menu depending on the user's rights, in angularjs?

There is two similar questions: dynamic menu items using AngularJS How can I show or hide some buttons depend on the user's rights, in angularjs? I need to create a dynamic menu exactly like in the first similar question exept I cannot hardcode the rights in my page. An adminitrator can create custo...
1

votes
1

answer
322

views

Microsoft Visual Studio 2013 Stopped Working when adding connection

On the next screen when I click on Test Connection everything is fine. I get a successful connection. When I click on ok my Visual Studio crash without warning. What is wrong?
Bastien Vandamme
1

votes
2

answer
2.2k

views

SUMIFS a specific YEAR

Could you help me to fix this excel error? I'm trying to write a SUMIFS function. On my first page I have all my banking transaction sorted by date from 2011 to 2014. All transactions belong to one and only one category. I need to sum my value in Sum_range only if my two criteria are true. The year...
Bastien Vandamme
1

votes
2

answer
205

views

Represent a company network infrastructure with UML? [duplicate]

This question already has an answer here: What's the best way to represent a networked connection in a UML class diagram? 5 answers Is it possible to represent a company network infrastructure (router, firewall, switch but also real and virtual servers, VPN) with a UML diagram? What about the compo...
Bastien Vandamme
1

votes
3

answer
87

views

Why Linq Substring() ignore null value

I just realized that when I request this Orders.Where(y => y.Sub_Item_Id.Substring(0, 10) != y.Sub_Item_Site_Id.Substring(0, 10)) The query ignore all my null value that may exist in y.Sub_Item_Site_Id. So when I have a value in Sub_Item_Id and null in Sub_Item_Site_Id the query does NOT consider th...
Bastien Vandamme
1

votes
1

answer
63

views

Linq get latest date (or maximum value) of each element

I have a table that contain the history of balance of account. I would like to write a Linq query that return the last balance of each account. At this moment I use this query: var lastDate = AccountBalances.Max(y => y.BalanceDate); var listOfBalance = AccountBalances.Where(y => y.BalanceDate == las...
Bastien Vandamme
1

votes
1

answer
508

views

How to use default NEWID()/NEWSEQUENTIALID() with Guid/uniqueidentifier?

I have this table: CREATE TABLE [dbo].[SandTable]( [Id] [uniqueidentifier] NOT NULL, [Date] [date] NULL, CONSTRAINT [PK_SandTable] PRIMARY KEY) ALTER TABLE [dbo].[SandTable] ADD CONSTRAINT [DF_SandTable_Id] DEFAULT (NEWID()) FOR [Id] Question is not about using NEWID() vs NEWSEQUEN...
Bastien Vandamme
1

votes
1

answer
39

views

Cascading GroupJoin

Let's say we have 3 tables: Orders, OrderItems and OrderSubItems. A table of orders that contains order items that contains itself order sub items. So Orders: Id | Other columns O-123456 | O-789123 | O-456789 | OrderItems: Id | OrderId | Other columns OI-123456 | O-123456 | OI-123457 |...
Bastien Vandamme
1

votes
1

answer
79

views

OData InvalidOperationException. Bad Request - Error in query syntax

Working with ASP.NET Core and OData v4 I get a InvalidOperationException: The path template 'Classes({key})/Bookings({bookingKey})' on the action 'GetBooking' in controller 'Classes' is not a valid OData path template. Bad Request - Error in query syntax. I don't see the error in query syntax. Here...
Bastien Vandamme
1

votes
2

answer
56

views

Convert decimal to binary combination (of custom lenght)

I need to convert several decimal numbers (or a string or 1 and 0) to a binary combination. In .NET I see many libraries working with Byte. A Byte is a manipulation of 8 bits. In my case I have to work with set of 3 bit that I need to concatenate together. For example: for Filter or Partition I have...
Bastien Vandamme
1

votes
1

answer
0

views

Generate my links automatically

I would like to generate my links automatically via a static class in each of my aspx pages (or in a common BasePage). Currently I use this: private const string TEMPLATE = '~/One.aspx'; public static string Link () ( string link = String.Format(TEMPLATE); return link; ) But the name of my page, One...
1

votes
1

answer
0

views

Add a element in a non static object from a static method?

I know how to use nlog to log my information in a file but now I would like to redirect my log to a ListView (C#) and do some actions. So I directed my log to a method as explained in the documentation nlog. It works. Console.WriteLine works. It's not my problem. namespace SomeNamespace { using Syst...
Bastien Vandamme
1

votes
1

answer
0

views

Is it possible to update a live tile without the Windows Push Notification Service?

Is it possible to update a live tile without the Windows Push Notification Service? I would like to create an offline clock live tile.
Bastien Vandamme
1

votes
4

answer
102

views

In HTML is it possible to create asynchronous request without Ajax and/or Javascript?

I woulk like to know if with HTML is it possible to create asynchronous request without Ajax and/or JavaScript? I don't know if other methods exists to avoid full page reloads?
1

votes
2

answer
101

views

How can I quickly identify the path and the search pattern in C:\Users\Admin\Samples\*.pdf?

I would like to create a simple copy console application (I know copy already exists in DOS). Exactly like the DOS copy command I would like to be able to execute my copy application with two simple arguments: copy C:\Users\Admin\Samples\*.pdf C:\ Input path and search pattern Ouput path In my code...
Bastien Vandamme
1

votes
2

answer
33

views

What is the best way to return an entity with EF5.0?

I write this little part of code var query = from u in context.Users join ui in context.UserIdentifiers on u.id equals ui.user_fk where ui.identifier_value == identifier select new User = u; This code is wrong because of the last line select new User = u; So I wrote this var query = from u in contex...
Bastien Vandamme
1

votes
2

answer
62

views

keyword=“value” regular expression

My regular expression (?\w+)\s*=\s*\'(?\w+)\' is not correct to match all my keyword, value pair in my oauth_version='1.0', oauth_signature_method='HMAC-SHA1', oauth_nonce='K7WmP9YrR2oCYC3', oauth_timestamp='1413801976', oauth_consumer_key='test', oauth_signature='8ad2fZh23q%2FWfK6RykqcvhlLxH4%3D'...
Bastien Vandamme
5

votes
0

answer
46

views

Create, Update, Delete a $ref with ODate

After reading several tutorial I have a good idea how to implement a Rest API with OData. I can create, update and delete an entity and I can link existing entities to a collection of an entity. But what if my entity just contains another entity. Example, let's say I have a Course public class Cours...
Bastien Vandamme
1

votes
1

answer
3.9k

views

Why Rails ask me to run rake db:migrate RAILS_ENV=test again and again?

Could you help me with this issue: When executing [email protected]:~/projects/myproject-dev$ rake db:migrate:status database: myproject-db Status Migration ID Migration Name -------------------------------------------------- (...) up 20151104094107 Add need to something up 2015111108...
Bastien Vandamme
7

votes
2

answer
104

views

How can I set a timeout om my query on LinqPad on ExecuteQueryDynamic?

How can I set a timeout om my query on LinqPad on ExecuteQueryDynamic? Util.CurrentDataContext.ExecuteQueryDynamic($'SELECT count(*) FROM MyDb.dbo.{viewName}'); I would like to use this timeout to detect the too slow views. For each view I request a count but when my count take too much time I just...
Bastien Vandamme
1

votes
1

answer
1k

views

What is the purpose of BadRequest(ModelState)?

What is the utility of protected internal virtual InvalidModelStateResult BadRequest(ModelStateDictionary modelState); from public abstract class ApiController I juts tried to us it for my Web API if (!ModelState.IsValid) { var foo = BadRequest(ModelState); } but nothing happens Should I override i...
Bastien Vandamme
1

votes
1

answer
601

views

Using extension method with LinQPad

I have a project that use Entity Framework code first. I would like to use LinQpad to seed my database. To seed a database during the migration operation with Entity Framework I use the AddOrUpdate() extension method: context.Rule.AddOrUpdate( y => y.Id, new Rule() { Id = Guid.Parse('b9b4fc65-fd0b-...
Bastien Vandamme
1

votes
2

answer
1.8k

views

Are DataContext a kind of new version of DataSource?

What is a DataContext in C#? Are DataContext a kind of new version of DataSource?
Bastien Vandamme
1

votes
5

answer
1k

views

Queue Ajax request in Javascript?

I would like to execute an Ajax request every seconds. My next code work perfectly. window.onload = function () { setTimeout(doStuff, 1000); //wait before continuing } function doStuff() { $.ajax({ // ... }); setTimeout(doStuff, 1000); }; But at this moment if I use a tool like Fiddler to block my r...
1

votes
1

answer
801

views

Change the transport of a git repository

I created a new repository for one of my project on Gitlab/Github. I created it and started to use it with command line tools with SSH transport protocol. Now I'm using Visual Studio and Visual Studio 2013 doesn't support SSH. When I try to do a push I get this error message An error occurred. Detai...
Bastien Vandamme
18

votes
2

answer
13.2k

views

ODBC vs JDBC vs ADO.NET

What exactly are ODBC, JDBC and ADO.NET? What are the links between them?
Bastien Vandamme
5

votes
1

answer
13.8k

views

XAML textbox updated when TextChanged event

I use XAML and data binding (MVVM). I need to update a Label when my user write a new text character in a TextBox. XAML ViewModel class MainViewModel : NotifyPropertyChangedBase { private string _originalText = string.Empty; public string OriginalText { get { return _originalText; } set { _origina...
5

votes
5

answer
326

views

In C# could we imagine writing our own events without writing delegates?

I learned the object-oriented in Java. Now in develop in C#. This means that I never really understood the functioning of delagates but I know how to use them. Lately I discovered this page http://java.sun.com/docs/white/delegates.html. If Java is able to create event without delagates is it possibl...
Bastien Vandamme
2

votes
1

answer
196

views

Linq to Xml, is it possible to improve this query?

I am trying to learn LINQ to XML. I can not write a query correctly. What should I write to retrieve the list of code of the index MCCO? aaa bbb ccc ddd eee I already wrote this but I feel there is a way to improve query. I assume the fact there are codes (and not values) in my node. private List Ge...
Bastien Vandamme
5

votes
5

answer
4.2k

views

In C#, how can I use Regex.Replace to add leading zeroes (if possible)?

I would like to add a certain number of leading zeroes to a number in a string. For example: Input: 'page 1', Output: 'page 001' Input: 'page 12', Ouput: 'page 012' Input: 'page 123', Ouput: 'page 123' What's the best way to do this with Regex.Replace? At this moment I use this but the results are...
5

votes
5

answer
629

views

Is there a pattern or a method in C# to check if an (int 1,2,4,8,…) option is true or false

I like to write enum or integer to pass option to my methods. Is there a pattern or a method in C# to check if an (int 1,2,4,8,...) option is true or false. I think it should easily be possible via binary functions. class Program { public enum Option { Option_A = 1, Option_B = 2, Option_C = 4, Optio...
6

votes
4

answer
2.5k

views

Creating a new controller class in Visual Studio with MVC?

When I create a new controller in Visual Studio with MVC It generate automatically the following code : public class Default1Controller : Controller { // // GET: /Default1/ public ActionResult Index() { return View(); } } My Default1Controller inherit from Controller but I work with a BaseController...

View additional