This file contains 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
public IEnumerable<LocalizedBook> GetAll(string cultureCode) | |
{ | |
return (from b in this.storage.Books | |
join lName in this.storage.Localizations on b.NameId equals lName.LocalizationSetId | |
join lDescription in this.storage.Localizations on b.DescriptionId equals lDescription.LocalizationSetId | |
join lAuthor in this.storage.Localizations on b.AuthorId equals lAuthor.LocalizationSetId | |
where lName.CultureCode == cultureCode && lDescription.CultureCode == cultureCode && lAuthor.CultureCode == cultureCode | |
select new LocalizedBook() | |
{ | |
Id = b.Id, |
This file contains 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
SELECT "b"."Id", ( | |
SELECT "l"."Value" | |
FROM "Localizations" AS "l" | |
WHERE ("l"."CultureCode" = 'en') AND ("b.Name"."Id" = "l"."LocalizationSetId") | |
LIMIT 1 | |
) AS "Name", ( | |
SELECT "l0"."Value" | |
FROM "Localizations" AS "l0" | |
WHERE ("l0"."CultureCode" = 'en') AND ("b.Description"."Id" = "l0"."LocalizationSetId") | |
LIMIT 1 |
This file contains 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
public IEnumerable<LocalizedBook> GetAll(string cultureCode) | |
{ | |
return this.storage.Books.Select( | |
b => new LocalizedBook() | |
{ | |
Id = b.Id, | |
Name = b.Name.Localizations.FirstOrDefault(l => l.CultureCode == cultureCode).Value, | |
Description = b.Description.Localizations.FirstOrDefault(l => l.CultureCode == cultureCode).Value, | |
Author = b.Author.Localizations.FirstOrDefault(l => l.CultureCode == cultureCode).Value, | |
Year = b.Year |
This file contains 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
public interface ILocalizedBookRepository | |
{ | |
IEnumerable<LocalizedBook> GetAll(string cultureCode); | |
} |
This file contains 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
public class LocalizedBook | |
{ | |
public int Id { get; set; } | |
public string Name { get; set; } | |
public string Description { get; set; } | |
public string Author { get; set; } | |
public int Year { get; set; } | |
} |
This file contains 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
public class Culture | |
{ | |
public string Code { get; set; } | |
public string Name { get; set; } | |
} |
This file contains 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
public class Localization | |
{ | |
public int LocalizationSetId { get; set; } | |
public string CultureCode { get; set; } | |
public string Value { get; set; } | |
public virtual LocalizationSet LocalizationSet { get; set; } | |
public virtual Culture Culture { get; set; } | |
} |
This file contains 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
public class LocalizationSet | |
{ | |
public int Id { get; set; } | |
public virtual ICollection<Localization> Localizations { get; set; } | |
} |
This file contains 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
public class Book | |
{ | |
public int Id { get; set; } | |
public int NameId { get; set; } | |
public int DescriptionId { get; set; } | |
public int AuthorId { get; set; } | |
public int Year { get; set; } | |
public virtual LocalizationSet Name { get; set; } | |
public virtual LocalizationSet Description { get; set; } |
This file contains 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
public class Book | |
{ | |
public int Id { get; set; } | |
public string NameEn { get; set; } | |
public string NameUk { get; set; } | |
public string DescriptionEn { get; set; } | |
public string DescriptionUk { get; set; } | |
public string AuthorEn { get; set; } | |
public string AuthorUk { get; set; } | |
public int Year { get; set; } |