Comments (7)
its c# 6.0 ability.
string.Format("{0}=@fFirstNameParam", "FirstName")
equal to
$"{nameof(Entity.FirstName)}=@FirstNameParam"
second one has intellisense and refactoring advantage.
if you are new on c# try install visual studio 2015 and use lastes version of c# and .net framework.
from fastcrud.
Thank you for your fast reply. I'm sorry to say i must use Net 4.5. In your descrition you say it is possible. Please send me an example.
from fastcrud.
try this. its pure string way.
dbConnection.Find( whereClause:"FirstName=@FirstNameParam", orderClause:"LastName DESC", skipRowsCount:10, limitRowsCount:20, queryParameters: new {FirstNameParam: "John"});
from fastcrud.
Sorry it dosn't work. The compiler says "not a definition for Find with this parameter".
May be, I'm too stupid ;-)
from fastcrud.
@OleeOlsen First of all Ole, welcome to our wonderful C# world. It's beautiful, but it's not gonna be easy for you, as I myself have realized while trying to come up with this simple VB.NET example when I have zero experience in this language.
Imports System.Data.SqlClient
Imports Dapper.FastCrud
Module Module1
Sub Main()
Using conn As New SqlConnection
Dim persons = conn.Find(Of Person)(
whereClause := $"{NameOf(Person.FirstName)}=@FirstNameParam",
queryParameters := New With{.FirstNameParam="John"})
End Using
End Sub
End Module
I hope it makes sense. This translates to C# as follows:
using System.Data.SqlClient;
using Dapper.FastCrud;
namespace YourNamespace
{
class Program
{
static void Main(string[] args)
{
using (var conn = new SqlConnection())
{
var persons = conn.Find<Person>(
whereClause: $"{nameof(Person.FirstName)}=@FirstNameParam",
queryParameters: new { FirstNameParam="John" });
}
}
}
}
Both obviously assume there is a class Person
defined with FirstName
as a string property.
Regardless whether you want to write in VB.NET or C#, you have to use Visual Studio 2015. String interpolation is mostly a language feature, handled by the compiler, thus you can target even .NET 4.5 if you so desire. Just make sure that, before you add the FastCrud Nuget package, your project is already targeting that version of the framework in the Properties => Application screen.
from fastcrud.
@MoonStorm Thank you for this extendet reply. You shold write a requirement-section in the wiki.
I have now installed VS 2015 and use Net 4.5. And it woks. ;-)
from fastcrud.
You're right. I've added more on the front page. Thanks to you, now I know string interpolation was made available in VB 14 😆
from fastcrud.
Related Issues (20)
- Find returning less results with included relations with pagination HOT 1
- Using Multiple Where ... HOT 1
- Question: BulkInsert? HOT 1
- (Third-party library) Harbin.DataAccess - Generic Repository Pattern using Dapper, Dapper FastCRUD and DapperQueryBuilder HOT 2
- 2.6.7 -> 3.0.43 Breaks JOIN statements HOT 2
- Thread safety using different Dialects? HOT 6
- FastCrud seems to ignore TableAttribute on Entities on v3 HOT 2
- The "Discussions" tab is now available! (for non-issues)
- StrongName version? HOT 1
- Breaking changes in PropertyMapping<T>? HOT 3
- it's more complex HOT 4
- how to read the converted sql string HOT 1
- On large model generation errors HOT 2
- Unable to find any child-parent relationship for the child type HOT 3
- ForeignKey on navigation property not work HOT 2
- Sql.Format does ignores table schema HOT 1
- EnitityMapping overide to exclude columns not working as expected HOT 1
- RobiniaDocs API Explorer
- Relationship rework of Version 3 broke support for data classes that use custom implementations of GetHashCode HOT 3
- OrderBy method TStatementOptionsBuilder does not reflect alias HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fastcrud.