Creating dynamic linq queries


Linq, introduced with .NET Framework 4.5 is one of the best .NET developer friend. But have you ever think about creating dynamic queries with linq ? It can be sometimes useful if you have to inject dynamic expressions to your queries, for example let's say you have to write a query but need to resolve the field names at runtime because it depends on some rules defined in some configuration places.

Good news, there is a nuget package for this task !
Here is Linq.Dynamic, it allows to create linq queries such as :

var query =
    Where("City = @0 and Orders.Count >= @1", "London", 10).
    Select("new(CompanyName as Name, Phone)");

And many other features with this package... ;)

0 commentaires:

Library or Framework?


Do you use libraries, frameworks or both?
But wait a minute... What is the difference between a library and a framework?

Thanks to this article, you will find a couple of answers :)

0 commentaires:

Microsoft Band SDK available

Today, I would like to remember you that the Microsoft Band SDK is now available for developers ! You can also find the associated Xamarin component for iOS & Android platforms. Here are the links:

Xamarin Microsoft Band component for iOS & Android
Microsoft Band SDK download page

With this SDK you can access the following band sensors:

Provides X, Y, and Z acceleration in meters per second squared (m/s2) units.

Provides X, Y, and Z angular velocity in degrees per second (°/sec) units.

Distance :
Provides the total distance in centimeters, current speed in centimeters per second (cm/s), current pace in milliseconds per meter (ms/m), and the current pedometer mode (such as walking or running).

Heart Rate 
Provides the number of beats per minute, also indicates if the heart rate sensor is fully locked onto the wearer’s heart rate.

Provides the total number of steps the wearer has taken.

Skin Temperature
Provides the current skin temperature of the wearer in degrees Celius.

Provides the current ultra violet radition exposure intensity.

Device Contact 
Provides a way to let the developer know if someone is currently wearing the device.

Be creative, and if you develop an application with this SDK, don't hesitate to give your feedback and to share it with us...

0 commentaires:

A Web Game in an Hour


Want to learn more about web latest technologies with fun? You can have a look in here : You will build a 2D game using HTML, Javascript & CSS. It could be a good starting point for people that want to learn those technologies.

0 commentaires:

Xamarin.Forms device unique ID...

As in a lot of applications, you will probably need to get a unique identifier to identify a unique user.
And it becomes a little more complicated when you have to deal with different platforms like Android, iOS and Windows Phone...

Here is a simple solution that you can implement in Xamarin Forms that I found on this blog:

First define a service that you will use in your Xamarin Forms Application:

// Your service interface definition
public interface IDevice
   string GetIdentifier();  

// How you get your service in your app
IDevice device = DependencyService.Get();
string deviceIdentifier = device.GetIdentifier();

And here are the implementations for Android / Windows Phone and the most complicated, iOS platform:

[assembly: Xamarin.Forms.Dependency(typeof(WinPhoneDevice))]
namespace XFUniqueIdentifier.WinPhone
 public class WinPhoneDevice : IDevice
  public string GetIdentifier()
   byte[] myDeviceId = (byte[])Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("DeviceUniqueId");
   return Convert.ToBase64String(myDeviceId);

[assembly: Xamarin.Forms.Dependency(typeof(AndroidDevice))]
namespace XFUniqueIdentifier.Droid
 public class AndroidDevice : IDevice
  public string GetIdentifier()
   return Settings.Secure.GetString(Forms.Context.ContentResolver, Settings.Secure.AndroidId);

// iOS
[assembly: Xamarin.Forms.Dependency(typeof(IOSDevice))]
namespace XFUniqueIdentifier.iOS
 using System.IO;
 using System.Runtime.InteropServices;

 public class IOSDevice : IDevice
  private static extern uint IOServiceGetMatchingService(uint masterPort, IntPtr matching);

  private static extern IntPtr IOServiceMatching(string s);

  private static extern IntPtr IORegistryEntryCreateCFProperty(uint entry, IntPtr key, IntPtr allocator, uint options);

  private static extern int IOObjectRelease(uint o);

  public string GetIdentifier()
   string serial = string.Empty;
   uint platformExpert = IOServiceGetMatchingService(0, IOServiceMatching("IOPlatformExpertDevice"));
   if (platformExpert != 0)
    NSString key = (NSString) "IOPlatformSerialNumber";
    IntPtr serialNumber = IORegistryEntryCreateCFProperty(platformExpert, key.Handle, IntPtr.Zero, 0);
    if (serialNumber != IntPtr.Zero)
     serial = NSString.FromHandle(serialNumber);


   return serial;

Original post:

0 commentaires:

Xamarin & Caliburn.Micro


Good news for Caliburn.Micro users: it is now (almost) compatible with xamarin!

0 commentaires:

Unit Testing and Memory Profiling


You know Unit tests, you use it & it's good.
Sometimes, you want to ensure that you don't have memory leaks.

Here is a way of doing this. Jetbrains offers us a new soft to combine UT & Memory profiling. If you want to know more, you could have a look in here :

Happy coding!

0 commentaires:

Hey bloggers, insert code snippets in your posts !


You wonder how to to add nice code snippets in your blog posts ?
I have configured this blog to insert snippets (following this article):

The good tool used is SyntaxHighlighter:

All you have to do now is to insert your code in your post using the following <pre> TAG (in HTML mode):

// Comment
<pre class="brush: csharp">// Comment
public class Testing {
public Testing() {
public void Method() {
/* Another Comment
on multiple lines */
int x = 9;

Note that if your code contains '<' or '>' characters, you will need to encode it into HTML format, using a tool like this one:

Enjoy and write new posts !

0 commentaires:

Xamarin.Forms: Picker control and "Items" binding problem...

If I tell you "ComboBox", you will see quickly of which control I'm talking about. There no control named "ComboBox" in Xamarin.Forms but if you search a little, you will find the "Picker" control.

Class: Xamarin.Forms.Picker
In the namespace: Xamarin.Forms
Doc link:

The problem is that you cannot bind directly "Picker.Items" property in the XAML file ! For that you have to use the code behind file.

xaml (doesn't work):
<Picker Items="{Binding MyViewModelList}"... />

So what do we have to do ?

1- Name your "Picker" control in the xaml file (by adding an attribute like x:Name="uiPicker")

2- On the parent page in code behind, override the "OnBindingContextChanged( )" method

3- In this method, fill your "Picker.Items" property from your viewmodel's values.

4- On the XAML file, you can only bind the property "SelectedIndex" --> so thanks to this index (in your ViewModel), you will be able to get back your selected value.

<Picker SelectedIndex="{Binding MyValueIndex}"... />

Code behind:
protected override void OnBindingContextChanged()
 MyViewModel vm = BindingContext as MyViewModel;
  if (vm != null)
  foreach (var it in vm.MyViewModelList)

Note: If your list is dynamic (like an ObservableCollection), you will have to manage the "CollectionChanged" events to update your picker Items !

1 commentaires:

Mvvm From A to Z


For french developpers, you can have a look at my MVVM My Way article.

It proposes an end to end solution to developp an MVVM application.

This article covers the global architecture, the associated tools & the way of testing the app.

0 commentaires:

[Code de porc]


Code I have seen somewhere (in production code)

1 commentaires:

Syncfusion free eBooks !


Don't wait anymore!
Here is a list of kick starters books covering various subjects (Xamarin, Machine Learning, R, AngularJS...):

Don't hesitate to dowload, it is free!

1 commentaires: