-
-
Save quangquy87/54b11c8e01a434cc49a1e4a0b2048ace to your computer and use it in GitHub Desktop.
PKPL TEST
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// data.cs | |
// Created by quangquy87 on 2018/12/09 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using ServiceStack; | |
using ServiceStack.Text; | |
using ServiceStack.OrmLite; | |
using ServiceStack.OrmLite.SqlServer; | |
using ServiceStack.DataAnnotations; | |
[Alias("Customers")] | |
public class Customer | |
{ | |
[AutoIncrement,PrimaryKey] | |
public int CustomerId { get; set; } | |
public string Name { get; set; } | |
public string Code { get; set; } | |
public string IdentityCard { get; set; } | |
public string Phone { get; set; } | |
public string Address { get; set; } | |
public string Email { get; set; } | |
public short Birthday { get; set; } | |
public Sex Sex { get; set; } | |
} | |
[EnumAsInt] | |
public enum Sex : short | |
{ | |
Female = 1, | |
Male = 0, | |
Other = 2 | |
} | |
var dbFactory = new OrmLiteConnectionFactory("Data Source=112.78.2.206,1433;Initial Catalog=drph8739_pkpl;User Id=drph8739_user;Password=PKPL1qaz2wsx!@#;Integrated Security=False;MultipleActiveResultSets=true;", SqlServerDialect.Provider); | |
var db = dbFactory.Open(); | |
public List<Customer> SearchAsync(string query) | |
{ | |
var q = db.From<Customer>() | |
.Where(o => o.Name.Contains(query)) | |
.Or(o => o.Phone.Contains(query)) | |
.Or(o => o.IdentityCard.Contains(query)) | |
.Take(15); | |
return db.Select<Customer>(q); | |
} | |
var searchList=SearchAsync("trang"); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<packages> | |
<package id="ServiceStack.Text" version="5.2.0" targetFramework="net45" /> | |
<package id="ServiceStack.Interfaces" version="5.2.0" targetFramework="net45" /> | |
<package id="ServiceStack.Common" version="5.2.0" targetFramework="net45" /> | |
<package id="ServiceStack.OrmLite" version="5.2.0" targetFramework="net45" /> | |
<package id="ServiceStack.OrmLite.SqlServer" version="5.4.0" targetFramework="net45"/> | |
</packages> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment