-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
956 lines (842 loc) · 35.2 KB
/
index.html
File metadata and controls
956 lines (842 loc) · 35.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DataFuse Framework - Declarative Multi-Source Data Aggregation for .NET</title>
<meta name="description" content="DataFuse is a declarative .NET framework that aggregates data from SQL databases, REST APIs, and Entity Framework into unified, strongly-typed objects.">
<style>
:root {
--primary-color: #0969da;
--primary-dark: #0550ae;
--secondary-color: #656d76;
--accent-color: #7c3aed;
--success-color: #1a7f37;
--warning-color: #bf8700;
--danger-color: #cf222e;
--dark-color: #24292f;
--light-color: #f6f8fa;
--border-color: #d0d7de;
--text-primary: #24292f;
--text-secondary: #656d76;
--bg-primary: #ffffff;
--bg-secondary: #f6f8fa;
--code-bg: #f6f8fa;
--shadow-lg: 0 8px 24px rgba(140, 149, 159, 0.2);
--border-radius: 6px;
--font-mono: 'SFMono-Regular', 'Consolas', 'Liberation Mono', 'Menlo', monospace;
}
* { box-sizing: border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
line-height: 1.6;
color: var(--text-primary);
margin: 0;
padding: 0;
background: var(--bg-secondary);
font-size: 16px;
}
.container {
max-width: 1200px;
margin: 0 auto;
background: var(--bg-primary);
box-shadow: var(--shadow-lg);
min-height: 100vh;
}
.navbar {
background: var(--dark-color);
padding: 1rem 0;
position: sticky;
top: 0;
z-index: 100;
border-bottom: 1px solid #30363d;
}
.nav-container {
max-width: 1200px;
margin: 0 auto;
padding: 0 2rem;
display: flex;
align-items: center;
justify-content: space-between;
}
.logo {
color: #fff;
font-size: 1.25rem;
font-weight: 600;
text-decoration: none;
display: flex;
align-items: center;
}
.logo::before {
content: '\26A1';
margin-right: 0.5rem;
font-size: 1.5rem;
}
.nav-links {
display: flex;
list-style: none;
margin: 0;
padding: 0;
gap: 1.5rem;
}
.nav-links a {
color: #f0f6fc;
text-decoration: none;
padding: 0.5rem 0.75rem;
border-radius: var(--border-radius);
transition: all 0.2s ease;
font-size: 0.875rem;
font-weight: 500;
}
.nav-links a:hover {
background: rgba(240, 246, 252, 0.1);
color: #fff;
}
.header {
background: linear-gradient(135deg, #0969da 0%, #7c3aed 100%);
color: white;
padding: 4rem 2rem;
text-align: center;
}
.header h1 {
margin: 0 0 0.75rem;
font-size: 3rem;
font-weight: 700;
letter-spacing: -0.02em;
}
.header .tagline {
font-size: 1.25rem;
font-weight: 500;
opacity: 0.95;
margin-bottom: 1rem;
font-style: italic;
}
.header .subtitle {
font-size: 1rem;
opacity: 0.85;
font-weight: 400;
margin-bottom: 2rem;
max-width: 800px;
margin-left: auto;
margin-right: auto;
}
.header .badges {
display: flex;
justify-content: center;
gap: 0.5rem;
flex-wrap: wrap;
}
.badge {
background: rgba(255, 255, 255, 0.2);
color: white;
padding: 0.375rem 0.875rem;
border-radius: 20px;
font-size: 0.75rem;
font-weight: 500;
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.3);
}
.content { padding: 3rem 2rem; }
h2 {
color: var(--text-primary);
font-size: 2rem;
font-weight: 700;
margin-top: 3.5rem;
margin-bottom: 1.5rem;
padding-bottom: 0.5rem;
border-bottom: 1px solid var(--border-color);
scroll-margin-top: 5rem;
}
h3 {
color: var(--text-primary);
font-size: 1.5rem;
font-weight: 600;
margin-top: 2.5rem;
margin-bottom: 1rem;
scroll-margin-top: 5rem;
}
h4 {
color: var(--text-secondary);
font-size: 1.125rem;
font-weight: 600;
margin-top: 1.5rem;
margin-bottom: 0.75rem;
}
p {
margin-bottom: 1rem;
color: var(--text-secondary);
line-height: 1.75;
}
code {
background: var(--code-bg);
color: #d73a49;
padding: 0.2em 0.4em;
border-radius: 3px;
font-family: var(--font-mono);
font-size: 0.85em;
font-weight: 600;
border: 1px solid var(--border-color);
}
pre {
background: #0d1117;
border: 1px solid #30363d;
border-radius: var(--border-radius);
padding: 1rem;
overflow-x: auto;
margin: 1.5rem 0;
font-size: 0.875rem;
line-height: 1.5;
}
pre code {
background: none;
color: #e6edf3;
padding: 0;
border: none;
font-size: 0.875rem;
font-weight: 400;
}
.benefit-box {
background: #f0fdf4;
border: 1px solid #86efac;
border-left: 4px solid var(--success-color);
padding: 1.25rem 1.25rem 1.25rem 1.25rem;
border-radius: var(--border-radius);
margin: 1.5rem 0;
}
.benefit-box ul { margin: 0; padding-left: 1.5rem; }
.warning-box {
background: #fef2f2;
border: 1px solid #fca5a5;
border-left: 4px solid var(--danger-color);
padding: 1.25rem;
border-radius: var(--border-radius);
margin: 1.5rem 0;
}
.warning-box ul { margin: 0; padding-left: 1.5rem; }
.info-box {
background: #eff6ff;
border: 1px solid #93c5fd;
border-left: 4px solid var(--primary-color);
padding: 1.25rem;
border-radius: var(--border-radius);
margin: 1.5rem 0;
color: #1e40af;
}
.highlight-box {
background: #fffbeb;
border: 1px solid #fcd34d;
border-left: 4px solid var(--warning-color);
padding: 1.25rem;
border-radius: var(--border-radius);
margin: 1.5rem 0;
}
.install-box {
background: #f8fafc;
border: 1px solid var(--border-color);
border-left: 4px solid var(--accent-color);
padding: 1rem 1.25rem;
border-radius: var(--border-radius);
margin: 1.5rem 0;
font-family: var(--font-mono);
font-size: 0.875rem;
}
table {
width: 100%;
border-collapse: collapse;
margin: 1.5rem 0;
border: 1px solid var(--border-color);
border-radius: var(--border-radius);
overflow: hidden;
font-size: 0.875rem;
}
th, td {
padding: 0.75rem 1rem;
text-align: left;
border-bottom: 1px solid var(--border-color);
}
th {
background: var(--bg-secondary);
font-weight: 600;
color: var(--text-primary);
}
tbody tr:hover { background: #f8fafc; }
.flow-diagram {
background: var(--bg-secondary);
border: 1px solid var(--border-color);
border-radius: var(--border-radius);
padding: 2rem;
text-align: center;
margin: 2rem 0;
font-family: var(--font-mono);
font-size: 0.875rem;
}
.flow-diagram pre {
background: transparent;
border: none;
padding: 0;
margin: 0;
color: var(--text-primary);
font-weight: 500;
}
.use-case-card {
background: var(--bg-secondary);
border: 1px solid var(--border-color);
border-radius: var(--border-radius);
padding: 1.5rem;
margin: 1.5rem 0;
}
.use-case-card h4 {
color: var(--primary-color);
margin-top: 0;
font-size: 1.125rem;
}
.use-case-card .sources {
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
margin-bottom: 1rem;
}
.source-tag {
background: #dbeafe;
color: #1e40af;
padding: 0.25rem 0.75rem;
border-radius: 20px;
font-size: 0.75rem;
font-weight: 600;
}
.source-tag.api { background: #dcfce7; color: #166534; }
.source-tag.ext { background: #fef3c7; color: #92400e; }
.vs-label {
display: inline-block;
background: var(--accent-color);
color: white;
padding: 0.25rem 0.75rem;
border-radius: 4px;
font-size: 0.8rem;
font-weight: 600;
margin: 1rem 0;
}
ul, ol { margin-bottom: 1.5rem; padding-left: 2rem; }
li { margin-bottom: 0.5rem; color: var(--text-secondary); }
hr { border: none; height: 1px; background: var(--border-color); margin: 3rem 0; }
footer {
background: var(--dark-color);
color: #f0f6fc;
text-align: center;
padding: 3rem 2rem 2rem;
margin-top: 3rem;
}
footer p { color: #8b949e; margin: 0.5rem 0; }
footer .footer-links {
display: flex;
justify-content: center;
gap: 2rem;
margin-top: 1.5rem;
flex-wrap: wrap;
}
footer .footer-links a {
color: #7d8590;
text-decoration: none;
font-size: 0.875rem;
transition: color 0.2s ease;
}
footer .footer-links a:hover { color: #f0f6fc; }
@media (max-width: 768px) {
.header h1 { font-size: 2rem; }
.header .tagline { font-size: 1rem; }
.content { padding: 2rem 1rem; }
.nav-links { display: none; }
h2 { font-size: 1.5rem; }
.use-case-card .sources { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 480px) {
.header { padding: 2rem 1rem; }
.header h1 { font-size: 1.75rem; }
.header .badges { flex-direction: column; align-items: center; }
}
</style>
</head>
<body>
<div class="container">
<nav class="navbar">
<div class="nav-container">
<a href="#" class="logo">DataFuse</a>
<ul class="nav-links">
<li><a href="#use-cases">Use Cases</a></li>
<li><a href="#why-datafuse">Why DataFuse?</a></li>
<li><a href="#quick-start">Quick Start</a></li>
<li><a href="#packages">Packages</a></li>
<li><a href="https://github.com/CodeShayk/DataFuse.Net" target="_blank">GitHub</a></li>
</ul>
</div>
</nav>
<div class="header">
<h1>DataFuse Framework</h1>
<div class="tagline">Like GraphQL, but for your heterogeneous backend systems</div>
<div class="subtitle">A declarative .NET framework that aggregates data from SQL databases, REST APIs, MongoDB, and Entity Framework into unified, strongly-typed objects — replacing hundreds of lines of manual orchestration code.</div>
<div class="badges">
<span class="badge">.NET 9.0</span>
<span class="badge">NuGet</span>
<span class="badge">MIT License</span>
<span class="badge">Multi-Source</span>
<span class="badge">Type-Safe</span>
</div>
</div>
<div class="content">
<!-- USE CASES -->
<h2 id="use-cases">Real-World Use Cases</h2>
<p>DataFuse shines when a single response needs data from <strong>multiple backend systems</strong>. Here are scenarios where it eliminates boilerplate and adds automatic parallelism.</p>
<div class="use-case-card">
<h4>1. E-Commerce Product Page</h4>
<div class="sources">
<span class="source-tag">SQL Server — Inventory</span>
<span class="source-tag api">REST API — Pricing</span>
<span class="source-tag ext">MongoDB — Reviews</span>
</div>
<p>A product page combines inventory data from your SQL database, live pricing from a pricing microservice, and customer reviews from MongoDB. DataFuse fetches the product from SQL first, then runs pricing and MongoDB queries <strong>in parallel</strong>.</p>
<pre><code>public class ProductPageConfig : EntityConfiguration<ProductPage>
{
public override IEnumerable<Mapping<ProductPage, IQueryResult>> GetSchema()
{
return CreateSchema.For<ProductPage>()
.Map<ProductQuery, ProductTransform>(For.Paths("product"),
p => p.Dependents
.Map<PricingApiQuery, PricingTransform>(For.Paths("product/pricing"))
.Map<ReviewsMongoQuery, ReviewsTransform>(For.Paths("product/reviews")))
.End();
}
}</code></pre>
</div>
<div class="use-case-card">
<h4>2. Customer 360 Dashboard</h4>
<div class="sources">
<span class="source-tag">CRM Database</span>
<span class="source-tag api">Billing REST API</span>
<span class="source-tag api">Support Ticket API</span>
<span class="source-tag">Orders Database</span>
</div>
<p>Build a unified customer view from CRM data, billing history, support tickets, and order details — each from a different system. Use <strong>selective loading</strong> to fetch only what the current view needs.</p>
<pre><code>// Full customer 360
var customer = dataProvider.GetData(new CustomerRequest { CustomerId = 123 });
// Just profile + billing (skip tickets and orders)
var billing = dataProvider.GetData(new CustomerRequest
{
CustomerId = 123,
SchemaPaths = new[] { "customer", "customer/billing" }
});</code></pre>
</div>
<div class="use-case-card">
<h4>3. Multi-Service Reporting</h4>
<div class="sources">
<span class="source-tag">Sales Database</span>
<span class="source-tag api">Inventory API</span>
<span class="source-tag api">Shipping API</span>
<span class="source-tag">Revenue Database</span>
</div>
<p>Aggregate metrics from multiple microservices into a single report. Each data source is encapsulated in its own query, testable independently, and executed with automatic dependency management.</p>
</div>
<hr>
<!-- WHY DATAFUSE -->
<h2 id="why-datafuse">Why DataFuse?</h2>
<h3>The Problem</h3>
<p>In modern architectures, a single page or API response often needs data from <strong>multiple backend systems</strong>. The standard approach is manual orchestration code:</p>
<pre><code>// Without DataFuse: 50+ lines per data combination, repeated everywhere
var customer = await GetCustomerFromDatabase(customerId);
var orders = await GetOrdersFromAPI(customerId); // Sequential!
var billing = await GetBillingFromService(customerId); // Sequential!
var tickets = await GetTicketsFromAPI(customerId); // Sequential!
customer.Orders = orders;
customer.Billing = billing;
customer.Tickets = tickets;</code></pre>
<div class="warning-box">
<strong>Problems with manual orchestration:</strong>
<ul>
<li>Boilerplate explosion — every new data combination means 50+ lines of fetch-assemble code</li>
<li>No parallelism — developers write sequential calls unless they manually add <code>Task.WhenAll</code></li>
<li>Tight coupling — changing a data source means rewriting orchestration</li>
<li>No selective loading — you fetch everything even when consumers only need a subset</li>
<li>Inconsistent patterns — every developer solves the same problem differently</li>
</ul>
</div>
<span class="vs-label">VS</span>
<pre><code>// With DataFuse: declare once, use everywhere
var customer = dataProvider.GetData(new CustomerRequest { CustomerId = 123 });</code></pre>
<div class="benefit-box">
<strong>DataFuse gives you:</strong>
<ul>
<li><strong>Declarative schema</strong> — define data relationships once, reuse everywhere</li>
<li><strong>Automatic parallelism</strong> — sibling queries run in parallel, no <code>Task.WhenAll</code> needed</li>
<li><strong>Selective loading</strong> — fetch only the data paths the consumer needs</li>
<li><strong>Dependency management</strong> — parent results flow to child queries automatically</li>
<li><strong>Type safety</strong> — strongly-typed queries, results, and transformers</li>
<li><strong>Extensible adapters</strong> — add any data source by implementing <code>IQueryEngine</code></li>
</ul>
</div>
<h3>Comparison with Alternatives</h3>
<table>
<thead>
<tr>
<th>Capability</th>
<th>Manual Code</th>
<th>GraphQL</th>
<th>MediatR</th>
<th><strong>DataFuse</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>Multi-source aggregation</td>
<td>Manual wiring</td>
<td>Resolver-based</td>
<td>Manual wiring</td>
<td><strong>Declarative schema</strong></td>
</tr>
<tr>
<td>Parallel execution</td>
<td>Manual Task.WhenAll</td>
<td>Per-resolver</td>
<td>Manual</td>
<td><strong>Automatic</strong></td>
</tr>
<tr>
<td>Selective loading</td>
<td>Manual if/else</td>
<td>Built-in</td>
<td>Manual</td>
<td><strong>Schema path filtering</strong></td>
</tr>
<tr>
<td>Dependency management</td>
<td>Manual ordering</td>
<td>Implicit</td>
<td>Manual</td>
<td><strong>Parent-child hierarchy</strong></td>
</tr>
<tr>
<td>Type safety</td>
<td>Varies</td>
<td>Schema-based</td>
<td>Yes</td>
<td><strong>Strongly typed</strong></td>
</tr>
<tr>
<td>Learning curve</td>
<td>None</td>
<td>High (new language)</td>
<td>Low</td>
<td><strong>Low (C# only)</strong></td>
</tr>
<tr>
<td>Backend-only (no client changes)</td>
<td>Yes</td>
<td>No</td>
<td>Yes</td>
<td><strong>Yes</strong></td>
</tr>
</tbody>
</table>
<div class="highlight-box">
<strong>When to use DataFuse:</strong> Your data lives across <em>different systems</em> (SQL + APIs + external services) and you want declarative orchestration with automatic parallelism. <strong>When NOT to use it:</strong> All your data is in a single database and simple SQL joins suffice.
</div>
<hr>
<!-- QUICK START -->
<h2 id="quick-start">Quick Start (5 Minutes)</h2>
<h3>1. Install Packages</h3>
<div class="install-box">
<code>dotnet add package DataFuse.Integration</code><br>
<code>dotnet add package DataFuse.Adapters.SQL</code> — For SQL with Dapper<br>
<code>dotnet add package DataFuse.Adapters.WebAPI</code> — For REST APIs<br>
<code>dotnet add package DataFuse.Adapters.MongoDB</code> — For MongoDB<br>
<code>dotnet add package DataFuse.Adapters.EntityFramework</code> — For EF Core
</div>
<h3>2. Define Your Entity</h3>
<pre><code>public class Product : IEntity
{
public int ProductId { get; set; }
public string Name { get; set; }
public decimal Price { get; set; }
public Category Category { get; set; }
public Review[] Reviews { get; set; }
}</code></pre>
<h3>3. Create a Query</h3>
<pre><code>public class ProductQuery : SQLQuery<ProductResult>
{
protected override Func<IDbConnection, Task<ProductResult>> GetQuery(
IDataContext context, IQueryResult parentQueryResult)
{
var request = (ProductRequest)context.Request;
return connection => connection.QueryFirstOrDefaultAsync<ProductResult>(
"SELECT ProductId as Id, Name, Price FROM Products WHERE ProductId = @Id",
new { Id = request.ProductId });
}
}
public class ReviewsMongoQuery : MongoQuery<CollectionResult<ReviewResult>>
{
protected override Func<IMongoDatabase, Task<CollectionResult<ReviewResult>>> GetQuery(
IDataContext context, IQueryResult? parentQueryResult)
{
var product = (ProductResult)parentQueryResult;
return async database =>
{
var collection = database.GetCollection<ReviewResult>("reviews");
var reviews = await collection.Find(r => r.ProductId == product.Id).ToListAsync();
return new CollectionResult<ReviewResult>(reviews);
};
}
}</code></pre>
<h3>4. Create Transformers</h3>
<pre><code>public class ProductTransform : BaseTransformer<ProductResult, Product>
{
public override void Transform(ProductResult queryResult, Product entity)
{
entity.ProductId = queryResult.Id;
entity.Name = queryResult.Name;
entity.Price = queryResult.Price;
}
}
public class ReviewsTransform : BaseTransformer<CollectionResult<ReviewResult>, Product>
{
public override void Transform(CollectionResult<ReviewResult> queryResult, Product entity)
{
entity.Reviews = queryResult?.Select(r => new Review
{
ReviewId = r.Id, Comment = r.Comment, Rating = r.Rating
}).ToArray() ?? Array.Empty<Review>();
}
}</code></pre>
<h3>5. Configure Schema</h3>
<pre><code>public class ProductConfiguration : EntityConfiguration<Product>
{
public override IEnumerable<Mapping<Product, IQueryResult>> GetSchema()
{
return CreateSchema.For<Product>()
.Map<ProductQuery, ProductTransform>(For.Paths("product"),
product => product.Dependents
.Map<CategoryQuery, CategoryTransform>(For.Paths("product/category"))
.Map<ReviewsMongoQuery, ReviewsTransform>(For.Paths("product/reviews")))
.End();
}
}</code></pre>
<h3>6. Register & Use</h3>
<pre><code>// Startup / DI registration
services.UseDataFuse()
.WithEngine(c => new QueryEngine(sqlConfiguration)) // SQL
.WithEngine<DataFuse.Adapters.WebAPI.QueryEngine>() // REST API
.WithEngine(c => new DataFuse.Adapters.MongoDB.QueryEngine(mongoDatabase)) // MongoDB
.WithPathMatcher(c => new XPathMatcher())
.WithEntityConfiguration<Product>(c => new ProductConfiguration());
services.AddHttpClient();
// Usage
public class ProductService
{
private readonly IDataProvider<Product> _dataProvider;
public ProductService(IDataProvider<Product> dataProvider)
=> _dataProvider = dataProvider;
public Product GetProduct(int productId)
=> _dataProvider.GetData(new ProductRequest { ProductId = productId });
public Product GetProductWithReviews(int productId)
=> _dataProvider.GetData(new ProductRequest
{
ProductId = productId,
SchemaPaths = new[] { "product", "product/reviews" }
});
}</code></pre>
<hr>
<!-- CORE CONCEPTS -->
<h2 id="core-concepts">Core Concepts</h2>
<h3>Entities</h3>
<p>Entities implement <code>IEntity</code> and define the complete object graph. Each property can be hydrated from a different data source:</p>
<pre><code>public class Customer : IEntity
{
public int CustomerId { get; set; }
public string Name { get; set; }
public Communication Communication { get; set; } // From REST API
public Address Address { get; set; } // From SQL
public Order[] Orders { get; set; } // From EF Core
}</code></pre>
<h3>Queries & Parent-Child Dependencies</h3>
<p>Child queries receive their parent's result, enabling dependent fetching across data sources:</p>
<pre><code>// Root: fetches from SQL
public class CustomerQuery : SQLQuery<CustomerResult> { /* uses request context */ }
// Child: uses parent CustomerResult to call API
public class OrdersApiQuery : WebQuery<CollectionResult<OrderResult>>
{
protected override Func<Uri> GetQuery(IDataContext context, IQueryResult parentQueryResult)
{
var customer = (CustomerResult)parentQueryResult;
return () => new Uri($"orders?customerId={customer.Id}", UriKind.Relative);
}
}</code></pre>
<h3>Execution Flow</h3>
<div class="flow-diagram">
<pre>1. Root Query executes first
|
v Result passed to children
2. Child Queries execute IN PARALLEL
- OrdersQuery, CommunicationQuery, AddressQuery
|
v Results passed to grandchildren
3. Grandchild Queries execute
- OrderItemsQuery (uses OrderId from parent)</pre>
</div>
<h3>Transformers</h3>
<p>Transformers map query results onto the entity. Each query-transformer pair handles one piece of the object graph:</p>
<pre><code>public class OrdersTransform : BaseTransformer<CollectionResult<OrderResult>, Customer>
{
public override void Transform(CollectionResult<OrderResult> queryResult, Customer entity)
{
entity.Orders = queryResult?.Select(o => new Order
{
OrderId = o.OrderId,
OrderNumber = o.OrderNumber,
OrderDate = o.OrderDate
}).ToArray() ?? Array.Empty<Order>();
}
}</code></pre>
<h3>Schema Configuration</h3>
<p>The schema declares the full hierarchy of queries, transformers, and path mappings:</p>
<pre><code>return CreateSchema.For<Customer>()
.Map<CustomerQuery, CustomerTransform>(For.Paths("customer"),
c => c.Dependents
.Map<CommunicationQuery, CommTransform>(For.Paths("customer/communication"))
.Map<OrdersQuery, OrdersTransform>(For.Paths("customer/orders"),
o => o.Dependents
.Map<ItemsQuery, ItemsTransform>(For.Paths("customer/orders/order/items"))))
.End();</code></pre>
<hr>
<!-- PACKAGES -->
<h2 id="packages">Packages</h2>
<table>
<thead>
<tr>
<th>Package</th>
<th>Purpose</th>
<th>.NET</th>
<th>.NET Standard</th>
<th>.NET Framework</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>DataFuse.Integration</code></td>
<td>Core orchestration, DI, helpers, path matchers</td>
<td>9.0+</td>
<td>2.0, 2.1</td>
<td>4.6.2+</td>
</tr>
<tr>
<td><code>DataFuse.Adapters.Abstraction</code></td>
<td>Interfaces & base classes (IEntity, IQuery, BaseTransformer)</td>
<td>9.0+</td>
<td>2.0, 2.1</td>
<td>4.6.2+</td>
</tr>
<tr>
<td><code>DataFuse.Adapters.SQL</code></td>
<td>SQL via Dapper (SQL Server, SQLite, MySQL, PostgreSQL)</td>
<td>9.0+</td>
<td>2.1</td>
<td>4.6.2+</td>
</tr>
<tr>
<td><code>DataFuse.Adapters.EntityFramework</code></td>
<td>Entity Framework Core with full LINQ support</td>
<td>9.0+</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td><code>DataFuse.Adapters.MongoDB</code></td>
<td>MongoDB via official driver</td>
<td>9.0+</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td><code>DataFuse.Adapters.WebAPI</code></td>
<td>REST APIs via HttpClient with header management</td>
<td>9.0+</td>
<td>2.0, 2.1</td>
<td>4.6.2+</td>
</tr>
</tbody>
</table>
<hr>
<!-- ADVANCED -->
<h2 id="advanced">Advanced Features</h2>
<h3>Selective Loading</h3>
<p>Fetch only the parts of the object graph you need via <code>SchemaPaths</code>:</p>
<pre><code>// Load everything
var full = dataProvider.GetData(new CustomerRequest { CustomerId = 123 });
// Load only customer + orders
var partial = dataProvider.GetData(new CustomerRequest
{
CustomerId = 123,
SchemaPaths = new[] { "customer", "customer/orders" }
});</code></pre>
<h3>Caching</h3>
<p>Mark query results with <code>[CacheResult]</code> to make them available across queries and transformers:</p>
<pre><code>[CacheResult]
public class CategoryResult : IQueryResult
{
public int Id { get; set; }
public string Name { get; set; }
}
// Access in a transformer
if (Context.Cache.TryGetValue("CategoryResult", out var cached))
{
entity.CategoryName = ((CategoryResult)cached).Name;
}</code></pre>
<h3>Custom Data Source Adapters</h3>
<p>Add support for any data source by implementing <code>IQueryEngine</code>:</p>
<pre><code>public class RedisQueryEngine : IQueryEngine
{
private readonly IConnectionMultiplexer _redis;
public RedisQueryEngine(IConnectionMultiplexer redis) => _redis = redis;
public bool CanExecute(IQuery query) => query is IRedisQuery;
public async Task<IQueryResult> Execute(IQuery query)
{
var redisQuery = (IRedisQuery)query;
return await redisQuery.Run(_redis.GetDatabase());
}
}
// Register alongside built-in adapters
services.UseDataFuse()
.WithEngine(c => new RedisQueryEngine(redisConnection))
.WithEngine(c => new QueryEngine(sqlConfig))
.WithEngine(c => new DataFuse.Adapters.MongoDB.QueryEngine(mongoDb));</code></pre>
<h3>Conditional Query Execution</h3>
<p>Skip queries based on parent data by returning <code>null</code>:</p>
<pre><code>protected override Func<Uri> GetQuery(IDataContext context, IQueryResult parentQueryResult)
{
var customer = (CustomerResult)parentQueryResult;
if (customer.CustomerType != "Premium")
return null; // Query is skipped
return () => new Uri($"premium/{customer.Id}", UriKind.Relative);
}</code></pre>
<h3>Path Matching</h3>
<p>DataFuse supports XPath and JSONPath patterns for schema paths:</p>
<table>
<thead>
<tr><th>XPath</th><th>JSONPath</th><th>Matches</th></tr>
</thead>
<tbody>
<tr><td><code>customer</code></td><td><code>$.customer</code></td><td>Root entity</td></tr>
<tr><td><code>customer/orders</code></td><td><code>$.customer.orders</code></td><td>Nested property</td></tr>
<tr><td><code>customer/orders/order/items</code></td><td><code>$.customer.orders[*].items</code></td><td>Deep nesting</td></tr>
</tbody>
</table>
</div>
<footer>
<h3 style="color: #f0f6fc; margin-top: 0;">DataFuse Framework</h3>
<p>Declarative multi-source data aggregation for .NET</p>
<div class="footer-links">
<a href="https://github.com/CodeShayk/DataFuse.Net">GitHub</a>
<a href="https://github.com/CodeShayk/DataFuse.Net/issues">Issues</a>
<a href="https://github.com/CodeShayk/DataFuse.Net/wiki">Wiki</a>
<a href="https://www.nuget.org/packages?q=DataFuse">NuGet</a>
</div>
</footer>
</div>
</body>
</html>