Comments (1)
UP
@schotime , Is there any documentation or example for this question?
Below is the data model that I want to map to NPoco, but it is not working, the failure occurs in the Employee property, where NPoco is not being able to map, probably because I made a mistake in the configuration or not this is not possible to do:
Entity:
public class EmployeeTask
{
public int Id { get; set; }
public int EmployeeId { get; set; }
public Employee Employee { get; set; } // Error here!
public string Name { get; set; }
public DateTime CreatedIn { get; set; }
public DateTime? UpdatedIn { get; set; }
public DateTime DeadLine { get; set; }
public bool Done { get; set; }
}
Mapping:
public class EmployeeTaskMapping : Map<EmployeeTask>
{
public EmployeeTaskMapping()
{
this.TableName("EmployeeTask");
this.PrimaryKey("Id");
this.Columns(x =>
{
x.Column(c => c.Id).WithName("Id");
x.Column(c => c.EmployeeId).WithName("EmployeeId");
x.Column(c => c.Employee).Reference(z => z.Id, ReferenceType.Foreign);
x.Column(c => c.Name).WithName("Name");
x.Column(c => c.CreatedIn).WithName("CreatedIn");
x.Column(c => c.UpdatedIn).WithName("UpdatedIn");
x.Column(c => c.DeadLine).WithName("DeadLine");
x.Column(c => c.Done).WithName("Done");
});
}
}
What I need to know is, instead of using query with flat SQL to resolve the foreign key issue, if it is possible to use query without using flat SQL, mapping the nested object. In the case of the data layer, I tried this here:
public async Task<List<EmployeeTask>> Retreave()
{
return await _context
.Query<EmployeeTask>()
.Include(x => x.Employee)
.ToListAsync();
}
... but no result
As I didn't find a practical example on the Wiki, I was testing the methods within the lambda to see what can be done. If you could help with this I would be grateful.
If you need more data, just ask.
from npoco.
Related Issues (20)
- No Tracking for Inserts HOT 1
- strongly typing IDs using implicit operator?
- One To Many References not working HOT 1
- Parameters are not working HOT 5
- InsertBulkAsync<T> fails with error: Cannot change DataType of a column once it has data. HOT 1
- new questions regarding multi-tenant apps
- Dependency injection example for context HOT 1
- SqliteConnection misdetected as SqlServerConnection HOT 1
- SQLite Insert Error : SQL logic error unrecognized token: @
- Hint() with PostgreSQL
- More than 4 Multiple Result Sets Mapping - 2
- Repository-wide license? HOT 1
- Why isn't DBConcurrencyException sent to IExceptionInterceptor?" HOT 1
- NullReferenceException / InvalidOperationException on multiple calls to Async Db method HOT 2
- Map string to json/jsonb field with PostgreSQL HOT 1
- Is version column in Sql Server supposed to be populated after an update?
- IMapper.GetParameterConverter sourceType parameter Is a different type between Insert and Update HOT 1
- NPOCO Does not map Composite Primary Key HOT 1
- culture bug??
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 npoco.