LiteDB Find() with DateTime.Year comparison doesn't have any result - c#

When using LiteCollection's instance method Find(), I passed a predicate into it as a parameter. This is the Find() method: stus.Find(s => s.Birthday.Year <= 1996);, and full code here:
Student.cs:
public class Student
{
public ObjectId ID { get; set; }
public string Name { get; set; }
public int Grade { get; set; }
public DateTime Birthday { get; set; }
}
Program.cs:
class Program
{
static void Main(string[] args)
{
using (var db = new LiteDatabase("test.db"))
{
LiteCollection<Student> stus = db.GetCollection<Student>("students");
List<Student> studentList = new List<Student>()
{
new Student() {Name = "Nguyen Hoang Nguyen", Birthday = new DateTime(1997, 6, 3), Grade = 8},
new Student() {Name = "Nguyen Anh Tuan", Birthday = new DateTime(1997, 7, 12), Grade = 8},
new Student() {Name = "Pham Van Hung", Birthday = new DateTime(1996, 3, 26), Grade = 9}
};
stus.Insert(studentList);
var filteredStudents = stus.Find(s => s.Birthday.Year <= 1996);
Console.WriteLine("Student who has birth year before 1996:");
foreach (Student filteredStudent in filteredStudents)
{
Console.WriteLine($"- {filteredStudent.Name}, grade: {filteredStudent.Grade}");
}
Console.ReadKey();
stus.Delete(_ => true);
}
}
}
But filteredStudents doesn't contain any student, only "Student who has birth year before 1996:" line was printed to the console. So is anything here wrong or I missed something here? Thank you for reading my question.

You can not do that in liteDB
You must create a DateTime Object
var d = new DateTime(1996);
var filteredStudents = stus.Find(s => s.Birthday.Year <= d);

Related

comparing two lists excluding a particular column in c#

Consider an entity named Employee which contains id,age and name as properties
I have two lists containing the Employee details
I have to compare the two lists excluding the id column
Please help with your suggestions
This will yield all the entries that are the same in both lists, ignoring the Id Property of your Employee:
var employees1 = new List<Employee>
{
new Employee(1, "Thomas", 12),
new Employee(2, "Alex", 24),
new Employee(3, "Tobias", 13),
new Employee(4, "Joshua", 12),
new Employee(5, "Thomas", 24)
};
var employees2 = new List<Employee>
{
new Employee(1, "Thomas", 12),
new Employee(2, "Yu", 24),
new Employee(3, "Max", 13),
new Employee(4, "Joshua", 30),
new Employee(5, "Maico", 13)
};
var duplicates = employees1.Intersect(employees2, new EmployeeComparer());
class EmployeeComparer : IEqualityComparer<Employee>
{
public bool Equals(Employee employee1, Employee employee2)
{
if (Object.ReferenceEquals(employee1, null) || Object.ReferenceEquals(employee2, null) ||
Object.ReferenceEquals(employee1, employee2)) return false;
return employee1.Name == employee2.Name && employee1.Age == employee2.Age;
}
public int GetHashCode(Employee employee)
{
return 0;
}
}
class Employee
{
public Employee(int id, string name, int age)
{
Id = id;
Name = name;
Age = age;
}
public int Id { get; set; }
public string Name { get; set; }
public int Age { get; set; }
}
As the post is tagged with LINQ I have used that in my answer.
static void Main(string[] args)
{
var list1 = new List<Person>();
var list2 = new List<Person>();
list1.Add(new Person(1, "james", "moon"));
list1.Add(new Person(1, "bob", "bar"));
list1.Add(new Person(1, "tim", "lane"));
list1.Add(new Person(1, "fizz", "sea"));
list2.Add(new Person(1, "buzz", "space"));
list2.Add(new Person(1, "james", "moon"));
var result = findDuplicates(list1, list2);
}
public static List<Person> findDuplicates(List<Person> l1, List<Person> l2)
{
return l1.Where(p => l2.Any(z => z.FName == p.FName && z.Addre == p.Addre)).ToList();
}
Person Class
public class Person
{
private int id;
private string fName;
private string addre;
public string Addre
{
get { return addre; }
set { addre = value; }
}
public string FName
{
get { return fName; }
set { fName = value; }
}
public int ID
{
get { return id; }
set { id = value; }
}
public Person(int i, string f, string a)
{
ID = i;
FName = f;
Addre = a;
}
}
Assuming Employee class:
class Employee
{
public int id { get; set; }
public int age { get; set; }
public string name { get; set; }
}
You can simply use Intersect :
var list1 = new List<Employee> {
new Employee{ id=2 , age=23, name="Hari"},
new Employee{ id=3 , age=10, name="Joe"},
new Employee{ id=4 , age=29, name="Daniel"},
};
var list2 = new List<Employee> {
new Employee{ id=1 , age=23, name="Hari"},
new Employee{ id=5 , age=10, name="Joe"},
new Employee{ id=6 , age=29, name="Daniel"},
};
var intersect = list1.Select(e => new { e.age, e.name }).Intersect(list2.Select(e => new { e.age, e.name })).ToList();

Sort 2 tables at the same time via using LinQ

My example contains 2 tables Book and Comment.
Book:
Id Name UserId DateTime
B1 Book1 User1 16/11/2016 11:15:00
B2 Book2 User1 16/11/2016 12:15:00
B3 Book3 User2 16/11/2016 10:15:00
Comment:
Id BookId UserId DateTime
C1 B3 User1 16/11/2016 11:17:00
C2 B1 User1 16/11/2016 11:16:00
List of Book via specific user id:
string userid = "User1";
IEnumerable<Book> books = _context.Books.Where(x => x.UserId == userid);
List of Comment:
IEnumerable<Book> comments = _context.Comments.Where(x => x.UserId == userid);
In activity history (web page), I want to show all books and comments what I have collected via userid, one by one. But, how can I sort 2 objects again via .OrderByDescending(x => x.DateTime)?
My goal:
User1 just postes a new book to the store:
B2 Book2 User1 16/11/2016 12:15:00
Before that, he posted a comment to his own thread:
C1 B1 User1 16/11/2016 11:17:00
Earlier, he posted a comment in another thread (UserId == "User2"):
C2 B3 User1 16/11/2016 11:16:00
Older, he posted a new book to the store:
B1 Book1 User1 16/11/2016 11:15:00
I can classify them via DateTime column (on paper):
16/11/2016 12:15:00
16/11/2016 11:17:00
16/11/2016 11:16:00
16/11/2016 11:15:00
How can I sort it?
UPDATE:
I just found a solution but LinQ. I want a solution using LinQ with same result (for shorter):
namespace MP
{
public class Book
{
public string Id { get; set; }
public string Name { get; set; }
public string UserId { get; set; }
public DateTime DateTime { get; set; }
}
public class Comment
{
public string Id { get; set; }
public string BookId { get; set; }
public string UserId { get; set; }
public string Content { get; set; }
public DateTime DateTime { get; set; }
}
public class Result
{
public object Object { get; set; }
public DateTime DateTime { get; set; }
}
class Program
{
static void Main()
{
try
{
string userid = "User1";
var books = new List<Book>();
books.Add(new Book { Id = "B1", Name = "Book1", UserId = "User1", DateTime = new DateTime(2016, 11, 16, 11, 15, 00) });
books.Add(new Book { Id = "B2", Name = "Book2", UserId = "User1", DateTime = new DateTime(2016, 11, 16, 12, 15, 00) });
books.Add(new Book { Id = "B3", Name = "Book3", UserId = "User2", DateTime = new DateTime(2016, 11, 16, 10, 15, 00) });
var comments = new List<Comment>();
comments.Add(new Comment { Id = "c1", BookId = "B3", UserId = "User1", Content = "cmt1", DateTime = new DateTime(2016, 11, 16, 11, 17, 00) });
comments.Add(new Comment { Id = "c2", BookId = "B1", UserId = "User1", Content = "cmt2", DateTime = new DateTime(2016, 11, 16, 11, 16, 00) });
var result = new List<Result>();
books.ForEach(x =>
{
if (x.UserId == userid)
{
result.Add(new Result { Object = x, DateTime = x.DateTime });
}
});
comments.ForEach(x =>
{
if (x.UserId == userid)
{
result.Add(new Result { Object = x, DateTime = x.DateTime });
}
});
result = result.OrderByDescending(x => x.DateTime).ToList();
foreach (var item in result)
{
Type type = item.Object.GetType();
if (type == typeof(MP.Book))
{
var book = (Book)item.Object;
Console.WriteLine($"Book: Id: {book.Id} - Name: {book.Name} - DateTime: {book.DateTime}");
}
if (type == typeof(MP.Comment))
{
var cmt = (Comment)item.Object;
Console.WriteLine($"Comment: Id: {cmt.Id} - Content: {cmt.Content} - DateTime: {cmt.DateTime}");
}
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}
}
Result:
Here's solution that should work for you. Basically I took your idea of objectifying the data and creating a linq query that creates a list of objects from each list and sorts them according to the DateTime. By overriding the ToString() method printing the contents of the list becomes very simple:
public class Book
{
public const string className = "Book";
public string Id { get; set; }
public string Name { get; set; }
public string UserId { get; set; }
public DateTime DateTime { get; set; }
public override string ToString()
{
return $"Book: Id: {Id.PadRight(7)} - Name: {Name.PadRight(14)} - DateTime: {DateTime}";
}
}
public class Comment
{
public string Id { get; set; }
public string BookId { get; set; }
public string UserId { get; set; }
public string Content { get; set; }
public DateTime DateTime { get; set; }
public override string ToString()
{
return $"Comment: Id: {Id.PadRight(7)} - Content: {Content.PadRight(11)} - DateTime: {DateTime}";
}
}
class Program
{
static void Main()
{
try
{
string userid = "User1";
var books = new List<Book>();
books.Add(new Book { Id = "B1", Name = "Book1", UserId = "User1", DateTime = new DateTime(2016, 11, 16, 11, 15, 00) });
books.Add(new Book { Id = "B2", Name = "Book2", UserId = "User1", DateTime = new DateTime(2016, 11, 16, 12, 15, 00) });
books.Add(new Book { Id = "B3", Name = "Book3", UserId = "User2", DateTime = new DateTime(2016, 11, 16, 10, 15, 00) });
var comments = new List<Comment>();
comments.Add(new Comment { Id = "c1", BookId = "B3", UserId = "User1", Content = "cmt1", DateTime = new DateTime(2016, 11, 16, 11, 17, 00) });
comments.Add(new Comment { Id = "c2", BookId = "B1", UserId = "User1", Content = "cmt2", DateTime = new DateTime(2016, 11, 16, 11, 16, 00) });
var test = (from b in books
where b.UserId == userid
select (object)b).Concat
(from c in comments
where c.UserId == userid
select (object)c).OrderBy(x => x.GetType() == typeof(Book)?((Book)x).DateTime:((Comment)x).DateTime);
foreach(var o in test)
{
Console.WriteLine(o);
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}
Did some more thinking, using generic objects always makes me uneasy, and came up with a better solution. by using a base class with the common properties and the book and comment classes deriving from that, the list you make can contain either book or comment and it can be filtered and sorted by any of the base class properties:
public class Item
{
public string Id { get; set; }
public string UserId { get; set; }
public DateTime DateTime { get; set; }
}
public class Book:Item
{
public string Name { get; set; }
public override string ToString()
{
return $"Book: Id: {Id.PadRight(7)} - Name: {Name.PadRight(14)} - DateTime: {DateTime}";
}
}
public class Comment:Item
{
public string BookId { get; set; }
public string Content { get; set; }
public override string ToString()
{
return $"Comment: Id: {Id.PadRight(7)} - Content: {Content.PadRight(11)} - DateTime: {DateTime}";
}
}
Creating the filtered and sorted list becomes much simpler:
string userid = "User1";
var items = new List<Item>();
items.Add(new Book { Id = "B1", Name = "Book1", UserId = "User1", DateTime = new DateTime(2016, 11, 16, 11, 15, 00) });
items.Add(new Book { Id = "B2", Name = "Book2", UserId = "User1", DateTime = new DateTime(2016, 11, 16, 12, 15, 00) });
items.Add(new Book { Id = "B3", Name = "Book3", UserId = "User2", DateTime = new DateTime(2016, 11, 16, 10, 15, 00) });
items.Add(new Comment { Id = "c1", BookId = "B3", UserId = "User1", Content = "cmt1", DateTime = new DateTime(2016, 11, 16, 11, 17, 00) });
items.Add(new Comment { Id = "c2", BookId = "B1", UserId = "User1", Content = "cmt2", DateTime = new DateTime(2016, 11, 16, 11, 16, 00) });
var test = (from b in items
where b.UserId == userid
orderby b.DateTime
select b);
foreach (var o in test)
{
Console.WriteLine(o);
}
Please try this one:
var vm = from b in Book
join c in Comment on b.Id equals c.BookId into d
where b.UserId == userid
orderby b.DateTime
select new {
OrderedDate = from item in d
orderby item.DateTime
select item
}
or another approach by UNION it
var vm = (from a in book
where a.UserId == userid
select new { a.DateTime })
.Union
(from b in Comment
where (x=> x.Book.Any(y=>y.UserId == userid))
select new { b.DateTime })
.Select(c => new { c.DateTime }).OrderBy(d => d.DateTime);
If I understand you correctly, you would like to display the records of two tables with different columns in a single grid.
Which columns are to be displayed?
Lets say they are ID, TYPE (either book entry or comment entry) and DT (DateTime).
var result = (from b in _context.Books
where b.UserId = userid
select new {b.Id Id, "BOOK" Type, b.DateTime DT})
.Union(
(from c in _context.Comments
where c.UserId = userid
select new {c.Id Id, "COMMENT" Type, c.DateTime DT})
).OrderByDescending(x => x.DT);
this is how i did,.
public class BookAndComment
{
public DateTime DateTime { get; set; }
public Book Book { get; set; }
public Comment Comment { get; set; }
}
and query
var orderedBooksAndComments = = books.Where(book => book.UserId == userId).Select(book =>
new BookAndComment
{
DateTime = book.DateTime,
Book = book
}).Union(comments.Where(comment => comment.UserId == userId).Select(comment =>
new BookAndComment
{
DateTime = comment.DateTime,
Comment = comment
}
)).OrderByDescending(bookAndComment => bookAndComment.DateTime).ToList();
than
foreach (var item in orderedBooksAndComments)
{
if(item.Book!=null)
{
// Do something
}else
{
var comment = item.Comment;
// comment should not be null here.
// Do something.
}
}

Seeding the database in Entity Framework

When I try to fill seed in my database I got an error:
The entity found was of type PetsOwner_FF460419E950312585B2229EA7AA6AEAA692190083B7EA5830FB08DEEE79E35D when an entity of type Caretaker was requested."
I went through all tips which I found, I examined the relation between classes and didn't find any solution.
context.CareTakers.AddOrUpdate(c => c.Id,
new Caretaker { Id = 1, Name = "Jan", Surname = "Nowak", Pesel = "29032400352", BankAccountNumber = "05 8202 1016 5582 6188 2074 1719", PhoneNumber = "666-449-292", Accomodations = new List<Accommodation> { context.Accomodations.Find(1) } },
new Caretaker { Id = 2, Name = "Anna", Surname = "Kowalski", Pesel = "29010209388", BankAccountNumber = "76 1610 1335 0163 2600 0322 4138", PhoneNumber = "789-335-709", Accomodations = new List<Accommodation> { context.Accomodations.Find(2) } },
new Caretaker { Id = 3, Name = "Sylwia", Surname = "Boski", Pesel = "42022605090", BankAccountNumber = "21 8499 0008 3163 0216 0506 9685", PhoneNumber = "538 -887-645", Accomodations = new List<Accommodation> { context.Accomodations.Find(3) } },
new Caretaker { Id = 4, Name = "Zbigniew", Surname = "Ryba", Pesel = "10262717572", BankAccountNumber = "61 9614 0008 9550 1997 2431 0213", PhoneNumber = "795-200-495", Accomodations = new List<Accommodation> { context.Accomodations.Find(4) } }
);
context.Accomodations.AddOrUpdate(a => a.Id,
new Accommodation { Id = 1, Beginning = new DateTime(2016, 1, 2), End = new DateTime(2016, 1, 3), PricePerDay = 10.5, Pet = context.Pets.Find(1), Caretaker = context.CareTakers.Find(1) },
new Accommodation { Id = 2, Beginning = new DateTime(2015, 2, 3), End = new DateTime(2016, 2, 4), PricePerDay = 100.0, Pet = context.Pets.Find(2), Caretaker = context.CareTakers.Find(2) },
new Accommodation { Id = 3, Beginning = new DateTime(2014, 9, 10), End = new DateTime(2016, 9, 11), PricePerDay = 12.3, Pet = context.Pets.Find(3), Caretaker = context.CareTakers.Find(3) },
new Accommodation { Id = 4, Beginning = new DateTime(2013, 11, 12), End = new DateTime(2016, 12, 13), PricePerDay = 41.4, Pet = context.Pets.Find(4), Caretaker = context.CareTakers.Find(4) }
);
My classes look like:
public class Accommodation {
public int Id { get; set; }//{BAG}
public virtual Caretaker Caretaker { get; set; }
public virtual Pet Pet { get; set; }
public double PricePerDay { get; set; }
public DateTime Beginning { get; set; }
public DateTime End { get; set; }
public double TotalPrice {
get {
return (End - Beginning).Days * PricePerDay;
}
}
}
[Table("Caretakers")]
public class Caretaker : Person {
public static int Percent => 20;//C# 6
public DateTime ObtainedLicense { get; set; }
public DateTime Hired { get; set; }
public double Salary => 0;
public virtual ICollection<Surgery> Surgeries { get; set; }
public virtual Vet Superior { get; set; }//rekurencyjna
//pochodny
public int AnimalsCurrentlyCareTaken => 0;//Lambda do wyliczenia ilosci opiekowaniymi sie zwierzetyami
public virtual ICollection<Accommodation> Accomodations { get; set; }
}

How to populate array element defined inside the class

How to populate array element defined inside the class? I would like to Populate List of student with array of Marks,which i am not able to locate .
public class Marks
{
public int ENG { get; set; }
public int MATHS { get; set; }
}
public class Student
{
public string empName { set; get; }
public string empAddress { set; get; }
public Marks[] StudentMarks { set; get; }
}
var objs = new List<Student>()
{
new Employee() {empName = "Manish" empAddress = "MUM"....array element with Marks of two subjects
new Employee() {empName = "Manoj", empAddress = "MUM"....arrayelement with Marks of two subjects
}
In order to initialize array in a single line you should use one of the following code
int[] n1 = new int[4] {2, 4, 6, 8};
int[] n2 = new int[] {2, 4, 6, 8};
int[] n3 = {2, 4, 6, 8};
In your case, you should populate your array with Marks objects.
Marks[] MarksArray = new [] {new Marks() {ENG = 1, MATHS = 1}, new Marks() {ENG = 2, MATHS = 2}};
This array contains 2 marks - new Marks() {ENG = 1, MATHS = 1} and new Marks() {ENG = 2, MATHS = 2}.
You can read find more examples here - https://msdn.microsoft.com/en-us/library/aa287601(v=vs.71).aspx
So you can create your objects this way
var objs = new List<Student>()
{
new Student() {empName = "Manish", empAddress = "MUM", StudentMarks = new [] {new Marks() {ENG = 1, MATHS = 1}, new Marks() {ENG = 2, MATHS = 2}} },
new Student() {empName = "Manish", empAddress = "MUM", StudentMarks = new [] {new Marks() {ENG = 1, MATHS = 1}, new Marks() {ENG = 2, MATHS = 2}} },
};
If you were concerned with the syntax only then this would do:
void Main()
{
var objs = new List<Employee>()
{
new Employee() {
empName = "Manish",
empAddress = "MUM",
StudentMarks = new Marks[] {
new Marks {ENG=10, MATHS = 100},
new Marks { ENG=20, MATHS = 80}, }},
new Employee() {
empName = "Manoj",
empAddress = "MUM",
StudentMarks = new Marks[] {
new Marks { ENG=59, MATHS = 40},
new Marks { ENG=60, MATHS = 80},
new Marks { ENG=80, MATHS = 10},
new Marks { MATHS = 90},
new Marks { ENG=70},}
},
};
foreach (var student in objs)
{
Console.WriteLine("{0} - {1}", student.empName, student.empAddress);
foreach (var mark in student.StudentMarks)
{
Console.WriteLine("Eng:{0}, Maths:{1}", mark.ENG, mark.MATHS);
}
}
}
public class Marks
{
public int ENG { get; set; }
public int MATHS { get; set; }
}
public class Student
{
public string empName { set; get; }
public string empAddress { set; get; }
public Marks[] StudentMarks { set; get; }
}
public class Employee : Student
{ }
However, that is not a good model. A better model would be like this:
void Main()
{
var objs = new List<Student>()
{
new Student() {
Name = "Manish",
Address = "MUM",
StudentMarks = new List<Mark> {
new Mark {Name="Eng", Score = 50},
new Mark {Name="Maths", Score = 60},
}
},
new Student() {
Name = "Manoj",
Address = "MUM",
StudentMarks = new List<Mark> {
new Mark {Name="Maths", Score = 100},
new Mark {Name="Eng", Score = 80},
new Mark {Name="Eng", Score = 70},
new Mark {Name="Eng", Score = 90},
new Mark {Name="Maths", Score = 90},
}
},
};
foreach (var student in objs)
{
Console.WriteLine("{0} - {1}", student.Name, student.Address);
foreach (var mark in student.StudentMarks)
{
Console.WriteLine("Name:{0}, Score:{1}", mark.Name, mark.Score);
}
}
}
public class Mark
{
public string Name { get; set; }
public int Score { get; set; }
}
public class Student
{
public string Name { set; get; }
public string Address { set; get; }
public List<Mark> StudentMarks { set; get; }
}
This one is still not very good. A better one might be:
void Main()
{
var objs = new List<Student>()
{
new Student() {
Name = "Manish",
Address = "MUM",
StudentMarks = new Dictionary<string,List<int>> {
{"Maths", new List<int> {60,70,50}},
{"Eng", new List<int> {80,70,90}},
}
},
new Student() {
Name = "Manoj",
Address = "MUM",
StudentMarks = new Dictionary<string,List<int>> {
{"Maths", new List<int> {70,90}},
{"Eng", new List<int> {40,50,60,60}},
}
},
};
foreach (var student in objs)
{
Console.WriteLine("{0} - {1}", student.Name, student.Address);
foreach (var course in student.StudentMarks)
{
Console.WriteLine("Course:{0}, Average:{1}", course.Key, course.Value.Average());
foreach (var score in course.Value)
{
Console.WriteLine(score);
}
}
}
}
public class Mark
{
public string Name { get; set; }
public int Score { get; set; }
}
public class Student
{
public string Name { set; get; }
public string Address { set; get; }
public Dictionary<string,List<int>> StudentMarks { set; get; }
}
And there are better ones.

Group join Linq C#

I am reading many sites to get a better idea of Linq -Group Join.
var customers = new Customer[]
{
new Customer{Code = 5, Name = "Sam"},
new Customer{Code = 6, Name = "Dave"},
new Customer{Code = 7, Name = "Julia"},
new Customer{Code = 8, Name = "Sue"}
};
// Example orders.
var orders = new Order[]
{
new Order{KeyCode = 5, Product = "Book"},
new Order{KeyCode = 6, Product = "Game"},
new Order{KeyCode = 7, Product = "Computer"},
new Order{KeyCode = 7, Product = "Mouse"},
new Order{KeyCode = 8, Product = "Shirt"},
new Order{KeyCode = 5, Product = "Underwear"}
};
var query = customers.GroupJoin(orders,
c => c.Code,
o => o.KeyCode,
(c, result) => new Result(c.Name, result));//why mention c here??
// Enumerate results.
foreach (var result in query)
{
Console.WriteLine("{0} bought...", result.Name);
foreach (var item in result.Collection)
{
Console.WriteLine(item.Product);
}
}
I couldnt understand why it gives (c, result) ? what if wrote as (c,o) ?
Can anyone share ideas on this?
These are just names of arguments passed to Func. You can use any name you want if that makes code more clear for you ie:
var query = customers.GroupJoin(orders,
c => c.Code,
o => o.KeyCode,
(something1, something2) => new Result(something1.Name, something2));
as it will just pass arguments from two previous Funcs into last one that is Func<TOuter, IEnumerable<TInner>, TResult>, so in that case Func<Customer, IEnumerable<Order>, Result>.
It's the same as with such situation:
public Result DoStuff(Order nameMeAnyWayYouWant, Customer meToo)
{
//do stuff here
}
Code from question is from: http://www.dotnetperls.com/groupjoin
I'm adding model classes that author skipped if anyone wants to elaborate and in case dotnetperls.com went down:
class Customer
{
public int Code { get; set; }
public string Name { get; set; }
}
class Order
{
public int KeyCode { get; set; }
public string Product { get; set; }
}
class Result
{
public string Name { get; set; }
public IEnumerable<Order> Collection { get; set; }
public Result(string name, IEnumerable<Order> collection)
{
this.Name = name;
his.Collection = collection;
}
}

Categories

Resources