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
No LinqToSql, para mapear um relacionamento entre entidades, vamos usar o exemplo do relacionamento Category e SubCategory. | |
/*########################################################*/ | |
1 - A subcategory que contém a chave estrangeira, deve conter um objeto "EntityRef<ProductCategory>" privado para ser armazenado a referência e um "Association" public, cujos Get e Set do Association apontam para o EntityRef. | |
/*########################################################*/ | |
private EntityRef<ProductCategory> _ProductCategory; | |
[Association(Storage = "_ProductCategory", ThisKey = "ProductCategoryID", IsForeignKey = true)] | |
public ProductCategory ProductCategory | |
{ |
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
No linqToSql você tem esses passos: | |
/* ############################################################################ */ | |
1 - Cria-se uma entidade (ProductCategory, por exemplo) | |
* Aponta ela como sendo a tabela por data notation; | |
* Aponta suas propriedades como sendo Colunas por data notation; | |
* Informa a propriedade que IsPrimaryKey | |
/* ############################################################################ */ | |
using System.Data.Linq.Mapping; |
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
class Produto | |
{ | |
public int Id { get; set; } | |
public string Nome { get; set; } | |
public string Numero { get; set; } | |
} | |
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
static void Main(string[] args) | |
{ | |
DataSet dsAdventure = PopularDataSet(); // metodo após o main | |
DataTable dtProduto = dsAdventure.Tables["Product"]; | |
IEnumerable<DataRow> produtos = | |
from p in dtProduto.AsEnumerable() | |
where p.Field<string>("Color") == "Black" // observe o campo Field<T> que faz a tipagem | |
orderby p.Field<string>("Name") descending | |
select p; |
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
XDocument doc = XDocument.Load(@"C:\Curso\C#\Linq\Contatos2.xml"); | |
IEnumerable<XElement> contatos = from c in doc.Descendants("Contato") | |
where c.Element("Endereco").Element("Bairro").Value == "Bairro XXX" | |
select c; | |
//Em sintaxe de método ficaria da seguinte forma: | |
//IEnumerable<XElement> contatos = doc.Descendants("Contato").Where(c => c.Element("Endereco").Element("Bairro").Value == "Bairro XXX"); |
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
static void CriarXmlLinq() | |
{ | |
XElement contatos = | |
new XElement("Contatos", | |
new XElement("Contato", | |
new XElement("Nome", "Thiago Mônaco"), | |
new XElement("Telefones", | |
new XElement("Telefone", "(11) 9999-9999", | |
new XAttribute("Tipo", "Celular")), |
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
####################### | |
A sintaxe de consulta disponibiliza as seguintes cláusulas]: | |
[from]: especifica a fonte de dados e uma variável de interação. | |
[where]: especifica um filtro booleano (podendo conter uma ou mais expressões lógicas) que será aplicado nos elementos da fonte de dados. | |
[select]: especifica o tipo e a forma que serão retornados os elementos da fonte de dados. | |
[group]: consulta grupo de acordo com o valor especificado. | |
[into]: fornece um identificador que pode servir de referência para resultados das cláusulas]: join, group e select. | |
[orderby]: ordena os resultados em ordem crescente (ascending) ou decrescente (descending). | |
[join]: une duas fontes de dados com base na comparação entre valores comuns nas fontes. | |
[let]: introduz uma variável de interação para ser utilizada com “sub” pesquisa. |
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
Imagem ilustrativa: | |
https://drive.google.com/file/d/1EfmukB65ESufhdwvMuwhmhbnD_ZCr1NB/view?usp=sharing | |
Como trabalhar? | |
1 - Elastic Cloud - elastic.co | |
2 - Levantando Docker | |
• instalar docker, pull da imagem do Elastic Search, Logstash e Kibana | |
• Configura o que quiser, normalmente com docker composer e criar várias imagens em uma subida só | |
• Para trabalhar em produção mesmo precisa de mais expertise: | |
* Cluster |
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
-- para aplicações C# é interessante ter um ignore para bin, obj, entre outros | |
1 - Crie na raiz do repositorio o arquivo .gitignore | |
2 - dentro dele coloque o seguinte conteúdo: | |
bin | |
obj | |
.vs | |
.vscode | |
.DS_Store |
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
-- Listagem de comandos para criação de vários tipos de projetos | |
dotnet new -h | |
-- Criando Solution para o projeto próprio da iBloom (iBloom apenas) (lembrando de voltar ao menu raiz) | |
dotnet new sln -n iBloom | |
-- Comandos para criação de projeto Class Library para Dominio e repositório (lembrando de voltar ao menu raiz) | |
dotnet new classlib -n iBloom.Dominio | |
dotnet new classlib -n iBloom.Repositorio | |
-- Adicionando referencia de Dominio em Repositorio (lembrando de voltar ao menu raiz) | |
dotnet add iBloom.Repositorio/iBloom.Repositorio.csproj reference iBloom.Dominio/iBloom.Dominio.csproj | |
-- Adicionando os dois projetos para a mesma solução |
NewerOlder