Dapper icon indicating copy to clipboard operation
Dapper copied to clipboard

UWP and dapper

Open stephane3434 opened this issue 9 years ago • 21 comments

Hello,

It's possible to use dapper with xamarin, and it works well for example on android with sqlserver as database.

To use it we all put the code database and dapper in a pcl library and we call it from several projects in xamarin forms (xamarin android, xamarin ios...)

Thanks to this, we can do the same code and the same screens for android, (ios), windows 8.1 and uwp

Xamarin + dapper is great

But idbconnection is not supported or more supported in UWP because not available in system.data

What can we do ?

Do you know if it is possible to replace idbconnection or does the reflective team have something for it?

stephane3434 avatar Jan 05 '17 05:01 stephane3434

is the non-interface abstract class supported?

(if so, I'm going to scream - we only recently fished those hacks out, since they were needed for early core-clr builds)

On 5 Jan 2017 5:34 a.m., "brnrd34" [email protected] wrote:

Hello,

It's possible to use dapper with xamarin, and it works well for example on android with sqlserver as database.

To use it we all put the code database and dapper in a pcl library and we call it from several projects in xamarin forms (xamarin android, xamarin ios...)

Thanks to this, we can do the same code and the same screens for android, (ios), windows 8.1 and uwp

Xamarin + dapper is great

But idbconnection is not supported or more supported in UWP because not available in system.data

What can we do ?

Do you know if it is possible to replace idbconnection or does the reflective team have something for it?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/StackExchange/dapper-dot-net/issues/673, or mute the thread https://github.com/notifications/unsubscribe-auth/AABDsFO33L0CA0sjShbt6i1dOoelz7xSks5rPIDtgaJpZM4LbXJf .

mgravell avatar Jan 05 '17 08:01 mgravell

Dapper supports netstandard, so the aim is that yes, we support UWP everywhere that supports netstandard1.3 or higher. Unfortunately though, it appears Windows Phone 8.1 (which Microsoft has pretty much abandoned) only supports up to netstandard1.2.

I'll poke Dapper later on current code and see what's broken in 1.2 and made us require 1.3, but IIRC it was some non-trivial items so absolutely no promises. I don't think adding a variant for before that is really practical, it's an environment that (AFAIK) this is the first request for.

I don't want to disappoint, but I have to be realistic: if that requires a non-minimal effort to support (PCLs at all), I wouldn't see it happening. That's all of the pain and confusion that netstandard aims to do away with going forward. Re-introducing it isn't likely. But I'll take a look and see how big of a gap there is with 1.2, that's totally reasonable to investigate. If it's the interfaces (what I think it is), that'll be a show stopper. I'll post when I get to this later this week.

NickCraver avatar Jan 05 '17 11:01 NickCraver

Took a quick peek, netstandard1.2 just isn't feasible, we're missing:

  • System.Collections.NonGeneric
  • System.Reflection.TypeExtensions
  • System.Xml.XmlDocument

And in these:

  • HashSet
  • PropertyInfo.GetGetMethod()
  • PropertyInfo.GetSetMethod()
  • Type.GetMethod()
  • TypeCode
  • XmlDocument

Unfortunately, TypeCode is a dealbreaker. That one's absolutely necessary for how type mapping works at the core of Dapper. Sorry, but we won't be able to support UWP 8.1 reasonably :(

NickCraver avatar Jan 05 '17 11:01 NickCraver

Last time I was checking on UWP 8.1 there was another problem:

  • System.Reflection.Emit.ILGeneration

erikpowa avatar Jan 05 '17 18:01 erikpowa

Hello, i have see, that idbconnection is not supported on uwp and just entity framework

http://stackoverflow.com/questions/32928434/how-to-reference-system-data-in-visual-studio-2015-targeting-net-core

You have an explain on : https://github.com/dotnet/corefx/issues/3480

image

Yesterday we created a basic uwp windows 10 project

Then we tried to add dapper component via nugets ...

We have an error directly.

stephane3434 avatar Jan 06 '17 08:01 stephane3434

What was your error with a Windows 10 project?

Side note: always post the error, that's what error messages exist for.

NickCraver avatar Jan 28 '17 13:01 NickCraver

It is not possible now to add dapper to a simple new uwp project via nuguet

My pc is a surface pro

The simple project :

UwpApp.zip

The nuget install error (in french) for dapper 1.5

Install-Package Dapper GET https://api.nuget.org/v3/registration1-gz/dapper/index.json OK https://api.nuget.org/v3/registration1-gz/dapper/index.json 218ms Restauration des packages pour 'UwpApp'. Restauration des packages pour P:\Workspaces\UwpApp\UwpApp\project.json... Install-Package : System.Reflection.Emit.Lightweight 4.0.1 fournit un assembly de références résolues à la compilation pour System.Reflection.Emit.Lightweight sur UAP,Version=v10.0, mais il n'existe pas d'assembly au moment de l'exécution compatible avec win10-arm-aot. Au caractère Ligne:1 : 1

  • Install-Package Dapper
  •   + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
      + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
    
    

Install-Package : System.Reflection.Emit.ILGeneration 4.0.1 fournit un assembly de références résolues à la compilation pour System.Reflection.Emit.ILGeneration sur UAP,Version=v10.0, mais il n'existe pas d'assembly au moment de l'exécution compatible avec win10-arm-aot. Au caractère Ligne:1 : 1

  • Install-Package Dapper
  •   + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
      + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
    
    

Install-Package : Un ou plusieurs packages sont incompatibles avec UAP,Version=v10.0 (win10-arm-aot). Au caractère Ligne:1 : 1

  • Install-Package Dapper
  •   + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
      + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
    
    

Install-Package : System.Reflection.Emit.Lightweight 4.0.1 fournit un assembly de références résolues à la compilation pour System.Reflection.Emit.Lightweight sur UAP,Version=v10.0, mais il n'existe pas d'assembly au moment de l'exécution compatible avec win10-x64-aot. Au caractère Ligne:1 : 1

  • Install-Package Dapper
  •   + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
      + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
    
    

Install-Package : System.Reflection.Emit.ILGeneration 4.0.1 fournit un assembly de références résolues à la compilation pour System.Reflection.Emit.ILGeneration sur UAP,Version=v10.0, mais il n'existe pas d'assembly au moment de l'exécution compatible avec win10-x64-aot. Au caractère Ligne:1 : 1

  • Install-Package Dapper
  •   + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
      + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
    
    

Install-Package : Un ou plusieurs packages sont incompatibles avec UAP,Version=v10.0 (win10-x64-aot). Au caractère Ligne:1 : 1

  • Install-Package Dapper
  •   + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
      + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
    
    

Install-Package : System.Reflection.Emit.Lightweight 4.0.1 fournit un assembly de références résolues à la compilation pour System.Reflection.Emit.Lightweight sur UAP,Version=v10.0, mais il n'existe pas d'assembly au moment de l'exécution compatible avec win10-x86-aot. Au caractère Ligne:1 : 1

  • Install-Package Dapper
  •   + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
      + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
    
    

Install-Package : System.Reflection.Emit.ILGeneration 4.0.1 fournit un assembly de références résolues à la compilation pour System.Reflection.Emit.ILGeneration sur UAP,Version=v10.0, mais il n'existe pas d'assembly au moment de l'exécution compatible avec win10-x86-aot. Au caractère Ligne:1 : 1

  • Install-Package Dapper
  •   + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
      + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
    
    

Install-Package : Un ou plusieurs packages sont incompatibles avec UAP,Version=v10.0 (win10-x86-aot). Au caractère Ligne:1 : 1

  • Install-Package Dapper
  •   + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
      + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
    
    

Échec de la restauration des packages pour 'UwpApp'. Install-Package : Échec de la restauration du package. Restauration des modifications du package pour 'UwpApp'. Au caractère Ligne:1 : 1

  • Install-Package Dapper
  •   + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
      + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
    

stephane3434 avatar Jan 30 '17 11:01 stephane3434

I'm no expert on why those libraries aren't supported on UWP 10, likely a PCL issue. But I know some!

@onovotny can you please chime in here? Does something equivalent exist in UWP land or is IL pretty much SOL?

NickCraver avatar Jan 30 '17 13:01 NickCraver

IL Emit is simply not supported on UWP. The closest you might have today is DispatchProxy: https://github.com/dotnet/corefx/blob/master/src/System.Reflection.DispatchProxy/src/System/Reflection/DispatchProxy.cs

But not sure how or why you're using IL Emit, so I can't say.

Keep in mind that IL Emit also doesn't work on iOS. At best it's interpreted there.

clairernovotny avatar Jan 30 '17 14:01 clairernovotny

I have a number of projects that are IL intensive (but in particular dapper and protobuf-net); long term I'm hoping that the in-progress code-emit tools (hooking into Roslyn) with offer some new options here. However, I tried about 8 weeks ago and nothing was viable. It is probably time for me to look again.

On 30 January 2017 at 14:00, Oren Novotny [email protected] wrote:

IL Emit is simply not supported on UWP.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/StackExchange/dapper-dot-net/issues/673#issuecomment-276069186, or mute the thread https://github.com/notifications/unsubscribe-auth/AABDsIKQ3CzinUimotEwLMsQbeTYkqX9ks5rXe0JgaJpZM4LbXJf .

-- Regards,

Marc

mgravell avatar Jan 30 '17 16:01 mgravell

Hello,

I see that in version Dapper V2 you do not plan to manage UWP. Am I Right ?

Microsoft "announces" "windows 10 Cloud" which only works with UWP and windows store

Do you think you will or will not?

Because with xamarin form a single project for windows 10, UWP, android, ios ... it's magic.

But without UWP no solution because it is the future of microrosft products that will no longer work

I love Dapper.

But we're stuck. We need to deliver applications android, ios and windows ... It seems to me important in version V2 to look at this point.

stephane3434 avatar Feb 05 '17 07:02 stephane3434

my understanding is that UWP has massive restrictions on metaprogramming. Dapper uses metaprogramming extensively.

This gives us three options:

  1. implement fallback implementations of everything with much worse performance
  2. pre-generate everything at compile-time using pre-alpha Roslyn bits
  3. don't support UWP at all

At the moment we are defaulting to 3 because 2 is not yet usable and we haven't found the time to do 1 (it isn't trivial). You are, AKAIK, the first person to ask about dapper on UWP - so that's a useful data point for our prioritization.

On 5 Feb 2017 7:15 a.m., "brnrd34" [email protected] wrote:

Hello,

I see that in version Dapper V2 you do not plan to manage UWP. Am I Right ?

Microsoft "announces" "windows 10 Cloud" which only works with UWP and windows store

Do you think you will or will not?

Because with xamarin form a single project for windows 10, UWP, android, ios ... it's magic.

But without UWP no solution because it is the future of microrosft products that will no longer work

I love Dapper.

But we're stuck. We need to deliver applications android, ios and windows ... It seems to me important in version V2 to look at this point.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/StackExchange/dapper-dot-net/issues/673#issuecomment-277502106, or mute the thread https://github.com/notifications/unsubscribe-auth/AABDsGbGgd0yWrSNhmsH-sDRbknp8XWoks5rZXclgaJpZM4LbXJf .

mgravell avatar Feb 05 '17 09:02 mgravell

I had a dream 2 years ago to unify the development of our applications

One code for all platforms (android, ios, windows10, uwp) .

A single access to all the databases on all platforms with DAPPER

I read about it and we did it about 10 months ago.

And it worked very well with "xamarin forms" + dapper ..

Today, following changes by microsoft, the windows part no longer works.

It is not Dapper's fault but Dapper is yet not compatible.

Microsoft turns 100% of its developments on the windows store and its UWP technology

Microsoft prepares a new Windows OS only UWP compatible... (WINDOWS 10 CLOUD)

Seeing what you are suggesting for V2 version of Dapper, it seemed logical to tell you "attention UWP becomes the main platform of microsoft .. You may have to look at it in version dapper V2"

Idbconnection is removed by microsoft and so nothing can work with Dapper now.

What should we do to tell you that with Dapper we found the only tool capable of running on all the platforms and databases we use.

I think many developers dream of having only one cross-platform, multi-database code but do not know it's possible today with xamarin and dapper

with a single DLL in PCL, we use it with windows PCs, with activex, with windows services, with IIS, on android applications, on ios applications...

Sorry to have been for you AKAIK.

I see today only one possible cross-platform solution is entity framework 7 - Entity Framework Core.

But having already worked with the EF5.. not enjoy

Nowadays to resolve to rebasculate on EF7 - Entity Framework Core that does not rejoice us.

I hope you understand our request

stephane3434 avatar Feb 05 '17 20:02 stephane3434

If there's no connection abstraction, UWP is going to be a world of pain. My disadvantage here is that my main technical expertise is "server". This means I don't have much direct knowledge of UWP. If you know how to make some of the things work, I'd be interested in PRs.

The code for the raw TDS parsers for both mono and .net core are now available, but it would still be a lot of pain to redo that layer.

I suspect Nick is in a very similar position re server vs UWP. I can try to look but I am perhaps not the ideal candidate.

mgravell avatar Feb 05 '17 23:02 mgravell

Do you think it's possible for option 1 to put in place some interfaces and only provides the Reflection.Emit implementation? That would open the possibility for the community to implement it own less performant implementation so you don't have to implement it?

pat-sc-philips avatar Feb 19 '17 19:02 pat-sc-philips

@pscraire This sort of thing is going to be supported in the runtime or it isn't. I don't think an interface really helps any here, but it would create overhead for an alternative implementation that will likely never exist. Either Dapper would have to fundamentally change in a major way, or UWP needs to add IL Emit support. The way in which we generate methods is so specific that it'd really be an interface with a single implementation...which brings us back to the same situation.

NickCraver avatar Feb 20 '17 00:02 NickCraver

Hello,

I come back to this post because, I know you have been working for a long time on NET STANDARD 2.

Do you think that with this, we will be able to use DAPPER on UWP?

If so, how can I do it because I did not see anything on UWP on StackExchange / DAPPER?

I saw that Visual studio 2017 V4 works with netstandard 2 + UWP,   it's a beginning !!! Https://github.com/dotnet/standard/issues/462

Thank you for your great work. I love DAPPER

stephane3434 avatar Nov 16 '17 00:11 stephane3434

netstandard 2.0 is very easy to port code to, since it's pretty much everything the full framework has, which the lesser versions having much limited surface.

According to a table here: https://github.com/dotnet/standard/blob/master/docs/versions.md

You can see starting from 10.0.16299, Version 1709 (Fall Creators Update), Windows 10 UWP will support netstandard 1.5, 1.6, 2.0.

So in theory, if you can wait the billions of PC to upgrade to 1709 (might take another year), you MIGHT able to use Dapper in UWP.

I say MIGHT because although it supports 2.0, it doesn't mean any code you compile does actually WORK within a UWP env, e.g. System.Console etc. Also I don't know how 1709 handles Emit, I remember that we are not allowed to emit new Types, purely for the security reason, someone might share some light here.

p.s. I'm curious to know your use case for Dapper for UWP, since currently there is very limited support of DB that works in UWP, Microsoft Officially suggest you to use sqlite, their SQL Compact doesn't work there at all, https://docs.microsoft.com/en-us/windows/uwp/data-access/

xied75 avatar Nov 16 '17 13:11 xied75

Hello,

Thank you for your answer, it's uyn epu what I understood.

To answer your question why UWP is simply that we have unified the code of all our applications into a single library.

we use languages ​​like C #, OMNIS, DELPHI, ANGULAR JS, WINDEV and the business application part is in the library.

Our applications are desktop + mobile, connected or disconnected.

Our job now is to make shared screens for multiple applications

Xamarin allows us to make android + ios + uwp (windows pc)

Soon Xamarin will make WPF and so UWP will not be needed specifically. (Xforms 3.x)

Using a web service is not possible in disconnected mode and you must reprogram everything in this case. Our library uses sqlserver, mysql and sqlite transparently for the same "business code"

today we can not deliver Xamarin applications on a pc or tablet because dapper does not work on this environment.

The idea is an application that runs on all connected or disconnected platforms.

We do not want to have a screen for each platform anymore.

So the idea would be to have XAML for the definition of screens and they are portable on all our applications.

After that we will miss the transition from XAML to HTML but that we are also studying it.

Here I hope you understand what we are trying to do one code for all our applications on all OS

good day to you

stephane3434 avatar Nov 17 '17 07:11 stephane3434

Hello,

As you know I'm trying to use xamarin and dapper for our developments

I followed the recommendations of xied75 and I switched my projects in netstandard.

Dapper 1.50.4 now works under android, ios and uwp (windows 10 - 1709)

With xamarin forms, by making a window it works on these 3 platforms and using a framework like mvvmcross it's magic ...

I discovered a problem using dapper and dapper.contrib.

Some functions did not work properly under android (I have not tested for IOS yet)

QuerySingleAsync crashes but not QueryAsync

updateAsync(object) also hangs and refuses to update with dapper.contrib.

I found a solution that seems strange enough to solve this problem (I have not tested for IOS for the moment)

When installing dapper under android, Dapper automatically installs, it seems to me, system.data. The problem is that this system.data is pointing to the .. \ monoandroid \ 1.0 folder.

image

  • If you replace this DLL by the dll of your pc coming from windows \ net.framework \ x86 \ net 4.0 or net 4.5
  • adding this dll to compile system.configuration.dll of the same folder

Everything works perfectly.

image

if you call a dll from another pcl or net.standard project in your project you must make the same change to the android project otherwise it will not work.

I hope this will correct this point or make changes to use monoandroid \ 1.0 \ system.data directly

For the moment, what is most important is that it seems to work well

Have a good day

stephane3434 avatar Dec 28 '17 20:12 stephane3434